46#include "llvm/ADT/SmallString.h"
47#include "llvm/ADT/Triple.h"
51#include <unordered_map>
58 Decl *Group[2] = { OwnedType, Ptr };
69 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass =
false,
70 bool AllowTemplates =
false,
71 bool AllowNonTemplates =
true)
72 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
73 AllowTemplates(AllowTemplates), AllowNonTemplates(AllowNonTemplates) {
74 WantExpressionKeywords =
false;
75 WantCXXNamedCasts =
false;
76 WantRemainingKeywords =
false;
81 if (!AllowInvalidDecl && ND->isInvalidDecl())
85 return AllowTemplates;
91 if (AllowNonTemplates)
97 auto *RD = dyn_cast<CXXRecordDecl>(ND);
98 if (!RD || !RD->isInjectedClassName())
101 return RD->getDescribedClassTemplate() ||
108 return !WantClassName && candidate.
isKeyword();
111 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
112 return std::make_unique<TypeNameValidatorCCC>(*
this);
116 bool AllowInvalidDecl;
119 bool AllowNonTemplates;
131 case tok::kw___int64:
132 case tok::kw___int128:
134 case tok::kw_unsigned:
142 case tok::kw__Float16:
143 case tok::kw___float128:
144 case tok::kw_wchar_t:
146 case tok::kw___underlying_type:
147 case tok::kw___auto_type:
150 case tok::annot_typename:
151 case tok::kw_char16_t:
152 case tok::kw_char32_t:
154 case tok::annot_decltype:
155 case tok::kw_decltype:
158 case tok::kw_char8_t:
169enum class UnqualifiedTypeNameLookupResult {
180static UnqualifiedTypeNameLookupResult
185 return UnqualifiedTypeNameLookupResult::NotFound;
187 UnqualifiedTypeNameLookupResult FoundTypeDecl =
188 UnqualifiedTypeNameLookupResult::NotFound;
191 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
192 BaseRD = BaseTT->getAsCXXRecordDecl();
196 if (!TST || !TST->isDependentType())
198 auto *TD = TST->getTemplateName().getAsTemplateDecl();
201 if (
auto *BasePrimaryTemplate =
202 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) {
204 BaseRD = BasePrimaryTemplate;
205 else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) {
207 CTD->findPartialSpecialization(
Base.getType()))
215 if (!isa<TypeDecl>(ND))
216 return UnqualifiedTypeNameLookupResult::FoundNonType;
217 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
219 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
221 case UnqualifiedTypeNameLookupResult::FoundNonType:
222 return UnqualifiedTypeNameLookupResult::FoundNonType;
223 case UnqualifiedTypeNameLookupResult::FoundType:
224 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
226 case UnqualifiedTypeNameLookupResult::NotFound:
233 return FoundTypeDecl;
241 UnqualifiedTypeNameLookupResult FoundTypeDecl =
242 UnqualifiedTypeNameLookupResult::NotFound;
244 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
248 RD = dyn_cast<CXXRecordDecl>(DC);
252 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
258 S.
Diag(NameLoc, diag::ext_found_in_dependent_base) << &II;
286 bool isClassName,
bool HasTrailingDot,
288 bool IsCtorOrDtorName,
289 bool WantNontrivialTypeSourceInfo,
290 bool IsClassTemplateDeductionContext,
293 bool AllowDeducedTemplate = IsClassTemplateDeductionContext &&
295 !isClassName && !HasTrailingDot;
317 if (!isClassName && !IsCtorOrDtorName)
322 if (WantNontrivialTypeSourceInfo)
351 if (ObjectTypePtr &&
Result.empty()) {
374 switch (
Result.getResultKind()) {
378 TypeNameValidatorCCC CCC(
true, isClassName,
379 AllowDeducedTemplate);
384 bool MemberOfUnknownSpecialization;
393 if (Correction && (NNS || NewII != &II) &&
399 Template, MemberOfUnknownSpecialization))) {
401 isClassName, HasTrailingDot, ObjectTypePtr,
403 WantNontrivialTypeSourceInfo,
404 IsClassTemplateDeductionContext);
407 PDiag(diag::err_unknown_type_or_class_name_suggest)
408 <<
Result.getLookupName() << isClassName);
411 *CorrectedII = NewII;
420 Result.suppressDiagnostics();
430 Result.suppressDiagnostics();
436 Res != ResEnd; ++Res) {
437 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) ||
451 Result.suppressDiagnostics();
462 IIDecl =
Result.getFoundDecl();
466 assert(IIDecl &&
"Didn't find decl");
469 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
473 auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
474 auto *FoundRD = dyn_cast<CXXRecordDecl>(TD);
475 if (!isClassName && !IsCtorOrDtorName && LookupRD && FoundRD &&
476 FoundRD->isInjectedClassName() &&
478 Diag(NameLoc, diag::err_out_of_line_qualified_id_type_names_constructor)
489 }
else if (AllowDeducedTemplate) {
497 Result.suppressDiagnostics();
504 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName &&
505 !isa<ObjCInterfaceDecl>(IIDecl)) {
506 if (WantNontrivialTypeSourceInfo) {
529 auto *ND = dyn_cast<NamespaceDecl>(DC);
530 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
532 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
534 RD->getTypeForDecl());
535 else if (isa<TranslationUnitDecl>(DC))
538 llvm_unreachable(
"something isn't in TU scope?");
549 if (
const auto *MD = dyn_cast<CXXMethodDecl>(DC))
550 if (MD->getParent()->hasAnyDependentBases())
558 bool IsTemplateTypeArg) {
559 assert(
getLangOpts().MSVCCompat &&
"shouldn't be called in non-MSVC mode");
562 if (IsTemplateTypeArg &&
getCurScope()->isTemplateParamScope()) {
571 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
577 RD->getTypeForDecl());
581 Diag(NameLoc, diag::ext_undeclared_unqual_id_with_dependent_base) << &II
616 switch (TD->getTagKind()) {
653 return S->isFunctionPrototypeScope();
663 bool IsTemplateName) {
668 SuggestedType =
nullptr;
672 TypeNameValidatorCCC CCC(
false,
false,
679 bool CanRecover = !IsTemplateName;
680 if (Corrected.isKeyword()) {
683 PDiag(IsTemplateName ? diag::err_no_template_suggest
684 : diag::err_unknown_typename_suggest)
686 II = Corrected.getCorrectionAsIdentifierInfo();
689 if (!SS || !SS->
isSet()) {
691 PDiag(IsTemplateName ? diag::err_no_template_suggest
692 : diag::err_unknown_typename_suggest)
695 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
696 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
697 II->
getName().equals(CorrectedStr);
700 ? diag::err_no_member_template_suggest
701 : diag::err_unknown_nested_typename_suggest)
702 << II << DC << DroppedSpecifier << SS->
getRange(),
705 llvm_unreachable(
"could not have corrected a typo here");
712 if (Corrected.getCorrectionSpecifier())
717 getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S,
718 tmpSS.
isSet() ? &tmpSS : SS,
false,
false,
nullptr,
728 Name.setIdentifier(II, IILoc);
731 bool MemberOfUnknownSpecialization;
733 Name,
nullptr,
true, TemplateResult,
744 Diag(IILoc, IsTemplateName ? diag::err_no_template
745 : diag::err_unknown_typename)
748 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
749 : diag::err_typename_nested_not_found)
755 unsigned DiagID = diag::err_typename_missing;
757 DiagID = diag::ext_typename_missing;
764 *SS, *II, IILoc).
get();
767 "Invalid scope specifier has already been diagnosed");
775 NextToken.
is(tok::less);
778 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
781 if (CheckTemplate && isa<TemplateDecl>(*I))
795 StringRef FixItTagName;
796 switch (Tag->getTagKind()) {
798 FixItTagName =
"class ";
802 FixItTagName =
"enum ";
806 FixItTagName =
"struct ";
810 FixItTagName =
"__interface ";
814 FixItTagName =
"union ";
818 StringRef TagName = FixItTagName.drop_back();
819 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
820 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
825 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
855 const Token &NextToken,
860 assert(NextToken.
isNot(tok::coloncolon) &&
861 "parse nested name specifiers before calling ClassifyName");
901 bool SecondTry =
false;
902 bool IsFilteredTemplateName =
false;
905 switch (
Result.getResultKind()) {
909 if (SS.
isEmpty() && NextToken.
is(tok::l_paren)) {
951 if (!SecondTry && CCC) {
956 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
957 unsigned QualifiedDiag = diag::err_no_member_suggest;
959 NamedDecl *FirstDecl = Corrected.getFoundDecl();
960 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
962 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
963 UnqualifiedDiag = diag::err_no_template_suggest;
964 QualifiedDiag = diag::err_no_member_template_suggest;
965 }
else if (UnderlyingFirstDecl &&
966 (isa<TypeDecl>(UnderlyingFirstDecl) ||
967 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
968 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
969 UnqualifiedDiag = diag::err_unknown_typename_suggest;
970 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
976 std::string CorrectedStr(Corrected.getAsString(
getLangOpts()));
977 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
978 Name->getName().equals(CorrectedStr);
981 << DroppedSpecifier << SS.
getRange());
985 Name = Corrected.getCorrectionAsIdentifierInfo();
988 if (Corrected.isKeyword())
994 Result.setLookupName(Corrected.getCorrection());
996 Result.addDecl(FirstDecl);
1016 Result.suppressDiagnostics();
1058 if (!
Result.isAmbiguous()) {
1059 IsFilteredTemplateName =
true;
1069 (IsFilteredTemplateName ||
1085 if (!IsFilteredTemplateName)
1088 bool IsFunctionTemplate;
1092 IsFunctionTemplate =
true;
1095 }
else if (!
Result.empty()) {
1111 IsFunctionTemplate =
true;
1115 if (IsFunctionTemplate) {
1119 Result.suppressDiagnostics();
1142 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
1143 Class = Alias->getClassInterface();
1149 if (NextToken.
is(tok::period)) {
1152 Result.suppressDiagnostics();
1160 if (isa<ConceptDecl>(FirstDecl))
1165 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
1166 !isa<VarTemplateDecl>(FirstDecl))
1172 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1173 if ((NextToken.
is(tok::identifier) ||
1194 Result.suppressDiagnostics();
1197 Result.getLookupNameInfo(), ADL,
Result.isOverloadedResult(),
1214 bool IsAddressOfOperand) {
1217 NameInfo, IsAddressOfOperand,
1224 const Token &NextToken) {
1242 if ((*ULE->decls_begin())->isCXXClassMember()) {
1244 SS.
Adopt(ULE->getQualifierLoc());
1249 Result.setNamingClass(ULE->getNamingClass());
1250 for (
auto I = ULE->decls_begin(), E = ULE->decls_end(); I != E; ++I)
1251 Result.addDecl(*I, I.getAccess());
1264 auto *TD = Name.getAsTemplateDecl();
1267 if (isa<ClassTemplateDecl>(TD))
1269 if (isa<FunctionTemplateDecl>(TD))
1271 if (isa<VarTemplateDecl>(TD))
1273 if (isa<TypeAliasTemplateDecl>(TD))
1275 if (isa<TemplateTemplateParmDecl>(TD))
1277 if (isa<ConceptDecl>(TD))
1284 "The next DeclContext should be lexically contained in the current one.");
1290 assert(
CurContext &&
"DeclContext imbalance!");
1293 assert(
CurContext &&
"Popped translation unit!");
1303 assert(
CurContext &&
"skipping definition of undefined tag");
1334 assert(!S->getEntity() &&
"scope already has entity");
1337 Scope *Ancestor = S->getParent();
1345 if (S->getParent()->isTemplateParamScope()) {
1353 assert(S->getEntity() ==
CurContext &&
"Context imbalance!");
1357 Scope *Ancestor = S->getParent();
1366 assert(S->isTemplateParamScope() &&
1367 "expected to be initializing a template parameter scope");
1391 for (; S && S->isTemplateParamScope(); S = S->getParent(), --ScopeDepth) {
1395 cast<Decl>(DC)->getDescribedTemplateParams()) {
1396 unsigned DCDepth = TPL->getDepth() + 1;
1397 if (DCDepth > ScopeDepth)
1399 if (ScopeDepth == DCDepth)
1404 S->setLookupEntity(SearchDCAfterScope);
1418 "The next DeclContext should be lexically contained in the current one.");
1422 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1425 if (Param->getIdentifier()) {
1435 assert(
CurContext &&
"DeclContext imbalance!");
1437 assert(
CurContext &&
"Popped translation unit!");
1468 while (S->getEntity() && S->getEntity()->isTransparentContext())
1483 if (isa<FunctionDecl>(D) &&
1484 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1490 for (; I != IEnd; ++I) {
1502 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1509 if (!S->isDeclScope(*I))
1522 bool AllowInlineNamespace) {
1530 if (ScopeDC->getPrimaryContext() == TargetDC)
1532 }
while ((S = S->getParent()));
1544 bool ConsiderLinkage,
1545 bool AllowInlineNamespace) {
1589 if (NewIsModuleInterface || OldIsModuleInterface) {
1595 << NewIsModuleInterface
1597 << OldIsModuleInterface
1637 return CD->isCopyConstructor();
1656 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1657 if (!RD->hasNameForLinkage())
1686 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1692 FD->getMemberSpecializationInfo() && !FD->isOutOfLine())
1695 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1700 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1704 if (FD->doesThisDeclarationHaveABody() &&
1707 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1717 if (VD->isStaticDataMember() &&
1720 if (VD->isStaticDataMember() &&
1722 VD->getMemberSpecializationInfo() && !VD->isOutOfLine())
1725 if (VD->isInline() && !
isMainFileLoc(*
this, VD->getLocation()))
1734 return mightHaveNonExternalLinkage(D);
1741 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1747 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1761 if (
auto *DD = dyn_cast<DecompositionDecl>(D)) {
1765 for (
auto *BD : DD->bindings())
1766 if (BD->isReferenced())
1777 if (isa<LabelDecl>(D))
1783 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1786 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1787 if (!WithinFunction)
1790 if (isa<TypedefNameDecl>(D))
1794 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1798 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1801 const auto *Ty = VD->getType().getTypePtr();
1811 if (Ty->isIncompleteType() || Ty->isDependentType())
1816 Ty = Ty->getBaseElementTypeUnsafe();
1819 const TagDecl *Tag = TT->getDecl();
1823 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1824 if (!RD->hasTrivialDestructor() && !RD->hasAttr<
WarnUnusedAttr>())
1827 if (
const Expr *Init = VD->getInit()) {
1829 dyn_cast<ExprWithCleanups>(Init))
1830 Init = Cleanups->getSubExpr();
1832 dyn_cast<CXXConstructExpr>(Init);
1836 (VD->getInit()->isValueDependent() || !VD->evaluateValue()))
1842 if (Init->isTypeDependent())
1844 if (!Ctor->isTrivial())
1858 if (isa<LabelDecl>(D)) {
1873 for (
auto *TmpD : D->
decls()) {
1874 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1876 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1887 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1898 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1899 DiagID = diag::warn_unused_exception_param;
1900 else if (isa<LabelDecl>(D))
1901 DiagID = diag::warn_unused_label;
1903 DiagID = diag::warn_unused_variable;
1913 bool Diagnose =
false;
1917 Diagnose = L->
getStmt() ==
nullptr;
1923 S->mergeNRVOIntoParent();
1925 if (S->decl_empty())
return;
1927 "Scope shouldn't contain decls!");
1929 for (
auto *TmpD : S->decls()) {
1930 assert(TmpD &&
"This decl didn't get pushed??");
1932 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1936 if (!S->hasUnrecoverableErrorOccurred()) {
1938 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1945 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1951 auto ShadowI = ShadowingDecls.find(D);
1952 if (ShadowI != ShadowingDecls.end()) {
1953 if (
const auto *FD = dyn_cast<FieldDecl>(ShadowI->second)) {
1955 << D << FD << FD->getParent();
1956 Diag(FD->getLocation(), diag::note_previous_declaration);
1958 ShadowingDecls.erase(ShadowI);
1978 bool DoTypoCorrection) {
1983 if (!IDecl && DoTypoCorrection) {
2027 (S->getEntity() && S->getEntity()->isTransparentContext()) ||
2045 return "ucontext.h";
2047 llvm_unreachable(
"unhandled error kind");
2058 Parent->addDecl(CLinkageDecl);
2072 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2075 FT->getParamType(i),
nullptr,
SC_None,
nullptr);
2077 Params.push_back(parm);
2079 New->setParams(Params);
2091 Scope *S,
bool ForRedeclaration,
2098 if (!ForRedeclaration)
2110 Diag(Loc, diag::warn_implicit_decl_no_jmp_buf)
2117 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
2123 if (!ForRedeclaration &&
2126 Diag(Loc, diag::ext_implicit_lib_function_decl)
2129 Diag(Loc, diag::note_include_header_or_declare)
2166 while (Filter.hasNext()) {
2175 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2177 Decl->getUnderlyingType()))
2182 if (OldTD->getAnonDeclWithTypedefName(
true) &&
2183 Decl->getAnonDeclWithTypedefName())
2196 OldType = OldTypedef->getUnderlyingType();
2204 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
2212 if (OldType != NewType &&
2218 << Kind << NewType << OldType;
2242 switch (TypeID->getLength()) {
2246 if (!TypeID->isStr(
"id"))
2249 if (!T->isPointerType())
2251 if (!T->isVoidPointerType()) {
2262 if (!TypeID->isStr(
"Class"))
2269 if (!TypeID->isStr(
"SEL"))
2296 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2297 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
2300 if (OldTag && NewTag &&
2301 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
2306 if (OldTD->isModed())
2308 OldTD->getUnderlyingType());
2317 if (isa<EnumDecl>(NewTag)) {
2319 for (
auto *D : NewTag->decls()) {
2324 ED->getLexicalDeclContext()->removeDecl(ED);
2374 if (!isa<TypedefNameDecl>(Old))
2408 for (
const auto *i : D->
attrs())
2409 if (i->getKind() == A->
getKind()) {
2411 if (Ann->
getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2416 if (OA && isa<OwnershipAttr>(i))
2425 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2426 return VD->isThisDeclarationADefinition();
2427 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2428 return TD->isCompleteDefinition() || TD->isBeingDefined();
2441 unsigned OldAlign = 0;
2449 if (I->isAlignmentDependent())
2456 if (Align > OldAlign) {
2458 OldStrictestAlignAttr = I;
2464 unsigned NewAlign = 0;
2466 if (I->isAlignmentDependent())
2473 if (Align > NewAlign)
2477 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2485 if (OldAlign == 0 || NewAlign == 0) {
2487 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2498 if (OldAlign != NewAlign) {
2502 S.
Diag(OldAlignasAttr->
getLocation(), diag::note_previous_declaration);
2517 S.
Diag(OldAlignasAttr->
getLocation(), diag::note_alignas_on_declaration)
2521 bool AnyAdded =
false;
2524 if (OldAlign > NewAlign) {
2532 if (OldAlignasAttr && !NewAlignasAttr &&
2533 !(AnyAdded && OldStrictestAlignAttr->
isAlignas())) {
2554 if (
const auto *AA = dyn_cast<AvailabilityAttr>(
Attr))
2556 D, *AA, AA->getPlatform(), AA->
isImplicit(), AA->getIntroduced(),
2557 AA->getDeprecated(), AA->getObsoleted(), AA->getUnavailable(),
2558 AA->getMessage(), AA->getStrict(), AA->getReplacement(), AMK,
2560 else if (
const auto *VA = dyn_cast<VisibilityAttr>(
Attr))
2562 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(
Attr))
2564 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(
Attr))
2566 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(
Attr))
2568 else if (
const auto *FA = dyn_cast<FormatAttr>(
Attr))
2569 NewAttr = S.
mergeFormatAttr(D, *FA, FA->getType(), FA->getFormatIdx(),
2571 else if (
const auto *SA = dyn_cast<SectionAttr>(
Attr))
2573 else if (
const auto *CSA = dyn_cast<CodeSegAttr>(
Attr))
2575 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(
Attr))
2577 IA->getInheritanceModel());
2578 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(
Attr))
2581 else if (S.
getLangOpts().CUDA && isa<FunctionDecl>(D) &&
2582 (isa<CUDAHostAttr>(
Attr) || isa<CUDADeviceAttr>(
Attr) ||
2583 isa<CUDAGlobalAttr>(
Attr))) {
2587 }
else if (
const auto *MA = dyn_cast<MinSizeAttr>(
Attr))
2589 else if (
const auto *SNA = dyn_cast<SwiftNameAttr>(
Attr))
2591 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(
Attr))
2593 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(
Attr))
2595 else if (
const auto *CommonA = dyn_cast<CommonAttr>(
Attr))
2597 else if (isa<AlignedAttr>(
Attr))
2601 else if ((isa<DeprecatedAttr>(
Attr) || isa<UnavailableAttr>(
Attr)) &&
2605 else if (
const auto *UA = dyn_cast<UuidAttr>(
Attr))
2606 NewAttr = S.
mergeUuidAttr(D, *UA, UA->getGuid(), UA->getGuidDecl());
2607 else if (
const auto *SLHA = dyn_cast<SpeculativeLoadHardeningAttr>(
Attr))
2609 else if (
const auto *SLHA = dyn_cast<NoSpeculativeLoadHardeningAttr>(
Attr))
2611 else if (
const auto *IMA = dyn_cast<WebAssemblyImportModuleAttr>(
Attr))
2613 else if (
const auto *INA = dyn_cast<WebAssemblyImportNameAttr>(
Attr))
2615 else if (
const auto *TCBA = dyn_cast<EnforceTCBAttr>(
Attr))
2617 else if (
const auto *TCBLA = dyn_cast<EnforceTCBLeafAttr>(
Attr))
2625 if (isa<MSInheritanceAttr>(NewAttr))
2634 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2635 return TD->getDefinition();
2636 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2642 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2644 if (FD->isDefined(Def,
true))
2651 for (
const auto *Attribute : D->
attrs())
2652 if (Attribute->getKind() == Kind)
2664 if (!Def || Def == New)
2668 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2669 const Attr *NewAttribute = NewAttributes[I];
2671 if (isa<AliasAttr>(NewAttribute) || isa<IFuncAttr>(NewAttribute)) {
2678 NewAttributes.erase(NewAttributes.begin() + I);
2686 ? diag::err_alias_after_tentative
2687 : diag::err_redefinition;
2689 if (
Diag == diag::err_redefinition)
2699 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2712 if (isa<C11NoReturnAttr>(NewAttribute)) {
2716 }
else if (isa<UuidAttr>(NewAttribute)) {
2720 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2721 if (AA->isAlignas()) {
2732 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2734 NewAttributes.erase(NewAttributes.begin() + I);
2738 }
else if (isa<LoaderUninitializedAttr>(NewAttribute)) {
2744 diag::err_loader_uninitialized_redeclaration);
2746 NewAttributes.erase(NewAttributes.begin() + I);
2750 }
else if (isa<SelectAnyAttr>(NewAttribute) &&
2751 cast<VarDecl>(New)->isInline() &&
2752 !cast<VarDecl>(New)->isInlineSpecified()) {
2759 }
else if (isa<OMPDeclareVariantAttr>(NewAttribute)) {
2767 diag::warn_attribute_precede_definition);
2769 NewAttributes.erase(NewAttributes.begin() + I);
2776 bool AttrBeforeInit) {
2783 std::string SuitableSpelling;
2785 SuitableSpelling = std::string(
2787 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
2789 InsertLoc, {tok::l_square, tok::l_square,
2790 S.PP.getIdentifierInfo(
"clang"), tok::coloncolon,
2791 S.PP.getIdentifierInfo(
"require_constant_initialization"),
2792 tok::r_square, tok::r_square}));
2793 if (SuitableSpelling.empty())
2795 InsertLoc, {tok::kw___attribute, tok::l_paren, tok::r_paren,
2796 S.PP.getIdentifierInfo(
"require_constant_initialization"),
2797 tok::r_paren, tok::r_paren}));
2798 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus20)
2799 SuitableSpelling =
"constinit";
2800 if (SuitableSpelling.empty() && S.
getLangOpts().CPlusPlus11)
2801 SuitableSpelling =
"[[clang::require_constant_initialization]]";
2802 if (SuitableSpelling.empty())
2803 SuitableSpelling =
"__attribute__((require_constant_initialization))";
2804 SuitableSpelling +=
" ";
2806 if (AttrBeforeInit) {
2809 assert(CIAttr->
isConstinit() &&
"should not diagnose this for attribute");
2817 CIAttr->
isConstinit() ? diag::err_constinit_added_too_late
2818 : diag::warn_require_const_init_added_too_late)
2843 if (
bool(OldConstInit) !=
bool(NewConstInit)) {
2851 (NewVD->hasInit() || NewVD->isThisDeclarationADefinition()))
2854 if (InitDecl == NewVD) {
2858 if (OldConstInit && OldConstInit->isConstinit())
2861 }
else if (NewConstInit) {
2865 if (InitDecl && InitDecl != NewVD) {
2878 if (!OldA->isEquivalent(NewA)) {
2881 Diag(OldA->getLocation(), diag::note_previous_declaration);
2883 }
else if (Old->
isUsed()) {
2894 for (
const auto &NewTag : NewAbiTagAttr->tags()) {
2895 if (std::find(OldAbiTagAttr->tags_begin(), OldAbiTagAttr->tags_end(),
2896 NewTag) == OldAbiTagAttr->tags_end()) {
2897 Diag(NewAbiTagAttr->getLocation(),
2898 diag::err_new_abi_tag_on_redeclaration)
2900 Diag(OldAbiTagAttr->getLocation(), diag::note_previous_declaration);
2904 Diag(NewAbiTagAttr->getLocation(), diag::err_abi_tag_on_redeclaration);
2911 if (
auto *VD = dyn_cast<VarDecl>(New)) {
2913 Diag(New->
getLocation(), diag::warn_attribute_section_on_redeclaration);
2922 !NewCSA->
isImplicit() && isa<CXXMethodDecl>(New)) {
2940 if (isa<DeprecatedAttr>(I) ||
2941 isa<UnavailableAttr>(I) ||
2942 isa<AvailabilityAttr>(I)) {
2956 if (isa<UsedAttr>(I))
2981 diag::err_carries_dependency_missing_on_first_decl) << 1;
2989 diag::note_carries_dependency_missing_first_decl) << 1;
2995 bool foundAny = newDecl->
hasAttrs();
3019 if (*Oldnullability != *Newnullability) {
3020 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
3045struct GNUCompatibleParamWarning {
3055template <
typename T>
3056static std::pair<diag::kind, SourceLocation>
3060 if (Old->isThisDeclarationADefinition())
3061 PrevDiag = diag::note_previous_definition;
3062 else if (Old->isImplicit()) {
3063 PrevDiag = diag::note_previous_implicit_declaration;
3065 OldLocation = New->getLocation();
3067 PrevDiag = diag::note_previous_declaration;
3068 return std::make_pair(PrevDiag, OldLocation);
3077 !LangOpts.CPlusPlus &&
3089template <
typename T>
3103template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
3109template<
typename ExpectedDecl>
3131 !Old->getDeclContext()->getRedeclContext()->Equals(
3132 New->getDeclContext()->getRedeclContext()) &&
3137 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
3155 AttrA->isDynamic() == AttrB->
isDynamic();
3181 if (NamedDC->Equals(SemaDC))
3184 assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
3186 "unexpected context for redeclaration");
3197 if (
auto *FD = dyn_cast<FunctionDecl>(NewD))
3198 FixSemaDC(FD->getDescribedFunctionTemplate());
3199 else if (
auto *VD = dyn_cast<VarDecl>(NewD))
3200 FixSemaDC(VD->getDescribedVarTemplate());
3215 Scope *S,
bool MergeTypeWithOld) {
3222 Diag(Shadow->getTargetDecl()->getLocation(),
3223 diag::note_using_decl_target);
3224 Diag(Shadow->getUsingDecl()->getLocation(),
3225 diag::note_using_decl) << 0;
3259 std::tie(PrevDiag, OldLocation) =
3266 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3273 Diag(OldLocation, PrevDiag);
3276 Diag(OldLocation, PrevDiag);
3304 const Decl *DiagOld = Old;
3306 auto OldIter = llvm::find_if(Old->
redecls(), [](
const Decl *D) {
3307 const auto *A = D->getAttr<OverloadableAttr>();
3308 return A && !A->isImplicit();
3312 DiagOld = OldIter == Old->
redecls_end() ? nullptr : *OldIter;
3317 diag::note_attribute_overloadable_prev_overload)
3346 bool RequiresAdjustment =
false;
3348 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC()) {
3354 if (!NewCCExplicit) {
3358 RequiresAdjustment =
true;
3370 RequiresAdjustment =
true;
3377 << (!FirstCCExplicit ?
"" :
3381 Diag(
First->getLocation(), diag::note_previous_declaration);
3389 RequiresAdjustment =
true;
3399 Diag(OldLocation, diag::note_previous_declaration);
3404 RequiresAdjustment =
true;
3411 <<
"'ns_returns_retained'";
3412 Diag(OldLocation, diag::note_previous_declaration);
3417 RequiresAdjustment =
true;
3426 Diag(OldLocation, diag::note_previous_declaration);
3431 RequiresAdjustment =
true;
3434 if (RequiresAdjustment) {
3464 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3493 OldDeclaredReturnType)) {
3501 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
3506 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
3516 if (OldReturnType != NewReturnType) {
3532 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
3534 if (OldMethod && NewMethod) {
3541 bool IsClassScopeExplicitSpecialization =
3547 !IsClassScopeExplicitSpecialization) {
3553 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3563 if (isa<CXXConstructorDecl>(OldMethod))
3564 NewDiag = diag::err_constructor_redeclared;
3565 else if (isa<CXXDestructorDecl>(NewMethod))
3566 NewDiag = diag::err_destructor_redeclared;
3567 else if (isa<CXXConversionDecl>(NewMethod))
3568 NewDiag = diag::err_conv_function_redeclared;
3570 NewDiag = diag::err_member_redeclared;
3574 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
3577 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3590 diag::err_definition_of_implicitly_declared_member)
3596 diag::err_definition_of_explicitly_defaulted_member)
3610 diag::note_noreturn_missing_first_decl);
3620 diag::err_carries_dependency_missing_on_first_decl) << 0;
3622 diag::note_carries_dependency_missing_first_decl) << 0;
3631 QualType OldQTypeForComparison = OldQType;
3636 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3651 Diag(OldLocation, PrevDiag);
3653 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3654 Diag(OldLocation, PrevDiag);
3683 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3684 (OldProto = dyn_cast<FunctionProtoType>(OldFuncType))) {
3687 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3691 OldProto->getExtProtoInfo());
3697 for (
const auto &ParamType : OldProto->param_types()) {
3702 Param->setScopeInfo(0, Params.size());
3703 Param->setImplicit();
3704 Params.push_back(Param);
3707 New->setParams(Params);
3742 NewProto->getReturnType());
3743 bool LooseCompatible = !MergedReturn.
isNull();
3745 LooseCompatible && Idx != End; ++Idx) {
3749 NewProto->getParamType(Idx))) {
3750 ArgTypes.push_back(NewParm->
getType());
3754 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3755 NewProto->getParamType(Idx) };
3756 Warnings.push_back(Warn);
3757 ArgTypes.push_back(NewParm->
getType());
3759 LooseCompatible =
false;
3762 if (LooseCompatible) {
3763 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3764 Diag(Warnings[Warn].NewParm->getLocation(),
3765 diag::ext_param_promoted_not_compatible_with_prototype)
3766 << Warnings[Warn].PromotedType
3767 << Warnings[Warn].OldParm->getType();
3768 if (Warnings[Warn].OldParm->getLocation().isValid())
3769 Diag(Warnings[Warn].OldParm->getLocation(),
3770 diag::note_previous_declaration);
3773 if (MergeTypeWithOld)
3793 Diag(OldLocation, diag::note_previous_builtin_declaration)
3798 PrevDiag = diag::note_previous_builtin_declaration;
3802 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3816 Scope *S,
bool MergeTypeWithOld) {
3831 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3845 if (!Merged.isNull() && MergeTypeWithOld)
3867 ni != ne && oi != oe; ++ni, ++oi)
3877 ? diag::err_redefinition_different_type
3878 : diag::err_redeclaration_different_type)
3883 std::tie(PrevDiag, OldLocation)
3885 S.
Diag(OldLocation, PrevDiag);
3897 bool MergeTypeWithOld) {
3925 QualType PrevVDTy = PrevVD->getType();
3979 if (MergeTypeWithOld)
4025 if (!shouldLinkPossiblyHiddenDecl(
Previous, New))
4035 OldTemplate = dyn_cast<VarTemplateDecl>(
Previous.getFoundDecl());
4039 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4043 Old = dyn_cast<VarDecl>(
Previous.getFoundDecl());
4046 dyn_cast<UsingShadowDecl>(
Previous.getRepresentativeDecl()))
4103 if (MostRecent != Old) {
4116 std::tie(PrevDiag, OldLocation) =
4126 Diag(OldLocation, PrevDiag);
4130 Diag(OldLocation, PrevDiag);
4149 Diag(OldLocation, PrevDiag);
4157 Diag(OldLocation, PrevDiag);
4163 Diag(OldLocation, PrevDiag);
4179 Diag(OldLocation, PrevDiag);
4189 Diag(Def->getLocation(), diag::note_previous_definition);
4203 Diag(OldLocation, PrevDiag);
4206 Diag(OldLocation, PrevDiag);
4214 Diag(OldLocation, PrevDiag);
4225 diag::warn_deprecated_redundant_constexpr_static_def);
4233 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
4234 Diag(OldLocation, PrevDiag);
4264 StringRef HdrFilename =
4267 auto noteFromModuleOrInclude = [&](
Module *Mod,
4273 if (IncLoc.isValid()) {
4275 Diag(IncLoc, diag::note_redefinition_modules_same_file)
4281 Diag(IncLoc, diag::note_redefinition_include_same_file)
4282 << HdrFilename.str();
4292 if (FNew == FOld && FNewDecLoc.second == FOldDecLoc.second) {
4297 EmittedDiag |= noteFromModuleOrInclude(getCurrentModule(), NewIncLoc);
4300 if (FOld && !HSI.isFileMultipleIncludeGuarded(FOld))
4355 ? S->getMSCurManglingNumber()
4356 : S->getMSLastManglingNumber();
4363 if (isa<CXXRecordDecl>(Tag->getParent())) {
4366 if (!Tag->getName().empty() || Tag->getTypedefNameForAnonDecl())
4378 Decl *ManglingContextDecl;
4379 std::tie(MCtx, ManglingContextDecl) =
4389struct NonCLikeKind {
4401 explicit operator bool() {
return Kind !=
None; }
4409 return {NonCLikeKind::Invalid, {}};
4416 return {NonCLikeKind::BaseClass,
4419 bool Invalid =
false;
4428 if (
auto *FD = dyn_cast<FieldDecl>(D)) {
4429 if (FD->hasInClassInitializer()) {
4430 auto *Init = FD->getInClassInitializer();
4431 return {NonCLikeKind::DefaultMemberInit,
4439 if (isa<FriendDecl>(D))
4444 if (isa<StaticAssertDecl>(D) || isa<IndirectFieldDecl>(D) ||
4447 auto *MemberRD = dyn_cast<CXXRecordDecl>(D);
4455 if (MemberRD->isLambda())
4456 return {NonCLikeKind::Lambda, MemberRD->getSourceRange()};
4460 if (MemberRD->isThisDeclarationADefinition()) {
4466 return {Invalid ? NonCLikeKind::Invalid : NonCLikeKind::None, {}};
4496 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TagFromDeclSpec);
4500 if (NonCLike || ChangesLinkage) {
4501 if (NonCLike.Kind == NonCLikeKind::Invalid)
4504 unsigned DiagID = diag::ext_non_c_like_anon_struct_in_typedef;
4505 if (ChangesLinkage) {
4507 if (NonCLike.Kind == NonCLikeKind::None)
4508 DiagID = diag::err_typedef_changes_linkage;
4510 DiagID = diag::err_non_c_like_anon_struct_in_typedef;
4516 TextToInsert +=
' ';
4519 Diag(FixitLoc, DiagID)
4522 if (NonCLike.Kind != NonCLikeKind::None) {
4523 Diag(NonCLike.Range.
getBegin(), diag::note_non_c_like_anon_struct)
4524 << NonCLike.Kind - 1 << NonCLike.Range;
4527 << NewTD << isa<TypeAliasDecl>(NewTD);
4550 llvm_unreachable(
"unexpected type specifier");
4560 bool IsExplicitInstantiation,
4562 Decl *TagD =
nullptr;
4577 if (isa<TagDecl>(TagD))
4580 Tag = CTD->getTemplatedDecl();
4585 Tag->setFreeStanding();
4586 if (Tag->isInvalidDecl())
4595 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
4630 bool IsExplicitSpecialization =
4631 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
4632 if (Tag && SS.
isNotEmpty() && !Tag->isCompleteDefinition() &&
4633 !IsExplicitInstantiation && !IsExplicitSpecialization &&
4634 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
4643 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
4649 bool DeclaresAnything =
true;
4652 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
4653 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
4656 Record->getDeclContext()->isRecord()) {
4665 AnonRecord = Record;
4670 DeclaresAnything =
false;
4689 if ((Tag && Tag->getDeclName()) ||
4693 Record = dyn_cast<RecordDecl>(Tag);
4696 Record = RT->getDecl();
4698 Record = UT->getDecl();
4706 DeclaresAnything =
false;
4718 if (
Enum->enumerator_begin() ==
Enum->enumerator_end() &&
4719 !
Enum->getIdentifier() && !
Enum->isInvalidDecl())
4720 DeclaresAnything =
false;
4728 DeclaresAnything =
false;
4732 Tag && Tag->getDeclContext()->isFunctionOrMethod())
4734 << Tag->getTagKind()
4747 if (!DeclaresAnything) {
4750 Diag(DS.
getBeginLoc(), (IsExplicitInstantiation || !TemplateParams.empty())
4751 ? diag::err_no_declarators
4752 : diag::ext_no_declarators)
4765 unsigned DiagID = diag::warn_standalone_specifier;
4767 DiagID = diag::ext_standalone_specifier;
4808 Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored)
4832 assert(PrevDecl &&
"Expected a non-null Decl");
4837 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
4839 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4864 bool Invalid =
false;
4867 for (
auto *D : AnonRecord->
decls()) {
4868 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4869 cast<NamedDecl>(D)->getDeclName()) {
4885 unsigned OldChainingSize = Chaining.size();
4887 Chaining.append(IF->chain_begin(), IF->chain_end());
4889 Chaining.push_back(VD);
4891 assert(Chaining.size() >= 2);
4894 for (
unsigned i = 0; i < Chaining.size(); i++)
4895 NamedChain[i] = Chaining[i];
4899 VD->
getType(), {NamedChain, Chaining.size()});
4911 Chaining.resize(OldChainingSize);
4926 "Parser allowed 'typedef' as storage class VarDecl.");
4927 switch (StorageClassSpec) {
4941 llvm_unreachable(
"unknown storage class specifier");
4945 assert(Record->hasInClassInitializer());
4947 for (
const auto *I : Record->decls()) {
4948 const auto *FD = dyn_cast<FieldDecl>(I);
4949 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4950 FD = IFD->getAnonField();
4951 if (FD && FD->hasInClassInitializer())
4952 return FD->getLocation();
4955 llvm_unreachable(
"couldn't find in-class initializer");
4960 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
4963 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4969 if (!
Parent->isUnion() || !
Parent->hasInClassInitializer())
4987 Diag(Record->getLocation(), diag::ext_anonymous_union);
4989 Diag(Record->getLocation(), diag::ext_gnu_anonymous_struct);
4991 Diag(Record->getLocation(), diag::ext_c11_anonymous_struct);
4995 bool Invalid =
false;
4997 const char *PrevSpec =
nullptr;
4998 if (Record->isUnion()) {
5008 !cast<NamespaceDecl>(OwnerScope)->isAnonymousNamespace()))) {
5009 Diag(Record->getLocation(), diag::err_anonymous_union_not_static)
5014 PrevSpec, DiagID, Policy);
5020 isa<RecordDecl>(Owner)) {
5022 diag::err_anonymous_union_with_storage_spec)
5036 << Record->isUnion() <<
"const"
5040 diag::ext_anonymous_struct_union_qualified)
5041 << Record->isUnion() <<
"volatile"
5045 diag::ext_anonymous_struct_union_qualified)
5046 << Record->isUnion() <<
"restrict"
5050 diag::ext_anonymous_struct_union_qualified)
5051 << Record->isUnion() <<
"_Atomic"
5055 diag::ext_anonymous_struct_union_qualified)
5056 << Record->isUnion() <<
"__unaligned"
5066 for (
auto *Mem : Record->decls()) {
5068 if (Mem->isInvalidDecl())
5071 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
5075 assert(FD->getAccess() !=
AS_none);
5077 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
5078 << Record->isUnion() << (FD->getAccess() ==
AS_protected);
5089 }
else if (Mem->isImplicit()) {
5091 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
5096 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
5097 if (!MemRecord->isAnonymousStructOrUnion() &&
5098 MemRecord->getDeclName()) {
5101 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
5102 << Record->isUnion();
5105 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
5106 << Record->isUnion();
5113 Diag(MemRecord->getLocation(),
5114 diag::ext_anonymous_record_with_anonymous_type)
5115 << Record->isUnion();
5117 }
else if (isa<AccessSpecDecl>(Mem)) {
5119 }
else if (isa<StaticAssertDecl>(Mem)) {
5124 unsigned DK = diag::err_anonymous_record_bad_member;
5125 if (isa<TypeDecl>(Mem))
5126 DK = diag::err_anonymous_record_with_type;
5127 else if (isa<FunctionDecl>(Mem))
5128 DK = diag::err_anonymous_record_with_function;
5129 else if (isa<VarDecl>(Mem))
5130 DK = diag::err_anonymous_record_with_static;
5134 DK == diag::err_anonymous_record_with_type)
5135 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
5136 << Record->isUnion();
5138 Diag(Mem->getLocation(), DK) << Record->isUnion();
5147 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
5150 cast<CXXRecordDecl>(Record));
5153 if (!Record->isUnion() && !Owner->
isRecord()) {
5154 Diag(Record->getLocation(), diag::err_anonymous_struct_not_member)
5174 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
5178 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
5195 Diag(Record->getLocation(), diag::err_mutable_nonmember);
5202 Record->getLocation(),
nullptr,
5214 Record->setAnonymousStructOrUnion(
true);
5225 Chain.push_back(Anon);
5230 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
5233 Decl *ManglingContextDecl;
5234 std::tie(MCtx, ManglingContextDecl) =
5266 assert(Record &&
"expected a record!");
5271 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
5279 nullptr, RecTy, TInfo,
5291 Chain.push_back(Anon);
5293 RecordDecl *RecordDef = Record->getDefinition();
5295 diag::err_field_incomplete_or_sizeless) ||
5299 ParentDecl->setInvalidDecl();
5315 NameInfo.
setLoc(Name.StartLocation);
5317 switch (Name.getKind()) {
5321 NameInfo.
setName(Name.Identifier);
5337 if (!Template || !isa<ClassTemplateDecl>(Template)) {
5338 Diag(Name.StartLocation,
5339 diag::err_deduction_guide_name_not_class_template)
5342 Diag(Template->getLocation(), diag::note_template_decl_here);
5353 Name.OperatorFunctionId.Operator));
5355 Name.OperatorFunctionId.SymbolLocations[0].getRawEncoding();
5357 = Name.EndLocation.getRawEncoding();
5393 if (!CurClass || CurClass->
getIdentifier() != Name.TemplateId->Name)
5429 llvm_unreachable(
"Unknown name kind");
5457 for (
unsigned Idx = 0; Idx <
Declaration->param_size(); ++Idx) {
5471 (DeclTyName && DeclTyName == DefTyName))
5472 Params.push_back(Idx);
5503 if (T.isNull() || !T->isInstantiationDependentType())
break;
5513 if (!TSI)
return true;
5525 if (
Result.isInvalid())
return true;
5580 while (Record && Record->isAnonymousStructOrUnion())
5581 Record = dyn_cast<CXXRecordDecl>(Record->getParent());
5582 if (Record && Record->getIdentifier() && Record->getDeclName() == Name) {
5583 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
5610 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
5624 Diag(Loc,
LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
5625 : diag::err_member_extra_qualification)
5629 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
5637 if (!Cur->
Encloses(DC) && !IsTemplateId) {
5639 Diag(Loc, diag::err_member_qualification)
5641 else if (isa<TranslationUnitDecl>(DC))
5642 Diag(Loc, diag::err_invalid_declarator_global_scope)
5644 else if (isa<FunctionDecl>(Cur))
5645 Diag(Loc, diag::err_invalid_declarator_in_function)
5647 else if (isa<BlockDecl>(Cur))
5648 Diag(Loc, diag::err_invalid_declarator_in_block)
5651 Diag(Loc, diag::err_invalid_declarator_scope)
5659 Diag(Loc, diag::err_member_qualification)
5681 if (dyn_cast_or_null<DecltypeType>(
5683 Diag(Loc, diag::err_decltype_in_declarator)
5723 if (!DC || isa<EnumDecl>(DC)) {
5729 diag::err_template_qualified_declarator_no_match)
5736 if (!IsDependentContext &&
5741 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
5743 diag::err_member_def_undefined_record)
5760 if (EnteringContext && IsDependentContext &&
5761 TemplateParamLists.size() != 0) {
5780 bool IsLinkageLookup =
false;
5781 bool CreateBuiltins =
false;
5795 IsLinkageLookup =
true;
5800 CreateBuiltins =
true;
5802 if (IsLinkageLookup) {
5841 Previous.getFoundDecl()->isTemplateParameter()) {
5871 bool AddToScope =
true;
5873 if (TemplateParamLists.size()) {
5907 bool &SizeIsNegative,
5908 llvm::APSInt &Oversized) {
5913 SizeIsNegative =
false;
5916 if (T->isDependentType())
5922 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5927 if (FixedType.
isNull())
return FixedType;
5929 return Qs.
apply(Context, FixedType);
5931 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5932 QualType Inner = PTy->getInnerType();
5936 if (FixedType.
isNull())
return FixedType;
5938 return Qs.
apply(Context, FixedType);
5948 SizeIsNegative, Oversized);
5958 llvm::APSInt Res =
Result.Val.getInt();
5961 if (Res.isSigned() && Res.isNegative()) {
5962 SizeIsNegative =
true;
5967 unsigned ActiveSizeBits =
5971 : Res.getActiveBits();
5979 return Qs.
apply(Context, FoldedArrayType);
6004 TypeLoc DstElemTL = DstATL.getElementLoc();
6023 bool &SizeIsNegative,
6024 llvm::APSInt &Oversized) {
6027 SizeIsNegative, Oversized);
6040 unsigned FailedFoldDiagID) {
6041 bool SizeIsNegative;
6042 llvm::APSInt Oversized;
6044 TInfo, S.
Context, SizeIsNegative, Oversized);
6046 S.
Diag(Loc, diag::ext_vla_folded_to_constant);
6053 S.
Diag(Loc, diag::err_typecheck_negative_array_size);
6054 else if (Oversized.getBoolValue())
6055 S.
Diag(Loc, diag::err_array_too_large) << Oversized.toString(10);
6056 else if (FailedFoldDiagID)
6057 S.
Diag(Loc, FailedFoldDiagID);
6089 diag::err_virtual_non_function);
6093 diag::err_explicit_non_function);
6097 diag::err_noreturn_non_function);
6120 << 1 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
6125 diag::err_deduction_guide_invalid_specifier)
6134 if (!NewTD)
return nullptr;
6155 if (T->isVariablyModifiedType()) {
6158 if (S->getFnParent() ==
nullptr) {
6159 bool SizeIsNegative;
6160 llvm::APSInt Oversized;
6171 else if (T->isVariableArrayType())
6173 else if (Oversized.getBoolValue())
6175 << Oversized.toString(10);
6200 Redeclaration =
true;
6206 if (ShadowedDecl && !Redeclaration)
6213 if (II->isStr(
"FILE"))
6215 else if (II->isStr(
"jmp_buf"))
6217 else if (II->isStr(
"sigjmp_buf"))
6219 else if (II->isStr(
"ucontext_t"))
6277 if (!OuterContext->
Equals(PrevOuterContext))
6286 if (!SS.
isSet())
return;
6295 unsigned kind = -1U;
6299 else if (!var->hasLocalStorage())
6301 }
else if (isa<ObjCIvarDecl>(
decl)) {
6303 }
else if (isa<FieldDecl>(
decl)) {
6308 Diag(
decl->getLocation(), diag::err_arc_autoreleasing_var)
6313 if (!type->isObjCLifetimeType())
6316 lifetime = type->getObjCARCImplicitLifetime();
6318 decl->setType(type);
6324 var->getTLSKind()) {
6325 Diag(var->getLocation(), diag::err_arc_thread_ownership)
6335 if (
Decl->getType().hasAddressSpace())
6337 if (
Decl->getType()->isDependentType())
6345 Var->hasGlobalStorage())
6349 if (
auto DT = dyn_cast<DecayedType>(
Type)) {
6350 auto OrigTy = DT->getOriginalType();
6351 if (!OrigTy.hasAddressSpace() && OrigTy->isArrayType()) {
6391 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
6392 if (VD->hasInit()) {
6394 assert(VD->isThisDeclarationADefinition() &&
6395 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
6407 diag::err_attribute_selectany_non_extern_data);
6413 auto *VD = dyn_cast<VarDecl>(&ND);
6414 bool IsAnonymousNS =
false;
6417 const NamespaceDecl *NS = dyn_cast<NamespaceDecl>(VD->getDeclContext());
6418 while (NS && !IsAnonymousNS) {
6420 NS = dyn_cast<NamespaceDecl>(NS->
getParent());
6427 bool AnonNSInMicrosoftMode = IsAnonymousNS && IsMicrosoft;
6429 (!AnonNSInMicrosoftMode &&
6439 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
6440 if (MD->isVirtual()) {
6442 diag::err_invalid_attribute_on_virtual_function)
6448 if (
const auto *FD = dyn_cast<FunctionDecl>(&ND)) {
6453 for (
TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
6460 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
6461 if (!MD || MD->isStatic()) {
6462 S.
Diag(A->getLocation(), diag::err_lifetimebound_no_object_param)
6463 << !MD << A->getRange();
6464 }
else if (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)) {
6465 S.
Diag(A->getLocation(), diag::err_lifetimebound_ctor_dtor)
6475 bool IsSpecialization,
6476 bool IsDefinition) {
6480 bool IsTemplate =
false;
6481 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl)) {
6482 OldDecl = OldTD->getTemplatedDecl();
6484 if (!IsSpecialization)
6485 IsDefinition =
false;
6487 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl)) {
6488 NewDecl = NewTD->getTemplatedDecl();
6492 if (!OldDecl || !NewDecl)
6502 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
6503 (NewExportAttr && !NewExportAttr->isInherited());
6509 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
6511 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
6513 bool JustWarn =
false;
6515 auto *VD = dyn_cast<VarDecl>(OldDecl);
6516 if (VD && !VD->getDescribedVarTemplate())
6518 auto *FD = dyn_cast<FunctionDecl>(OldDecl);
6527 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
6530 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
6531 : diag::err_attribute_dll_redeclaration;
6534 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
6547 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
6549 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl)) {
6552 IsStaticDataMember = VD->isStaticDataMember();
6553 IsDefinition = VD->isThisDeclarationADefinition(S.
Context) !=
6555 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
6556 IsInline = FD->isInlined();
6557 IsQualifiedFriend = FD->getQualifier() &&
6561 if (OldImportAttr && !HasNewAttr &&
6562 (!IsInline || (IsMicrosoftABI && IsTemplate)) && !IsStaticDataMember &&
6564 if (IsMicrosoftABI && IsDefinition) {
6566 diag::warn_redeclaration_without_import_attribute)
6574 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
6575 << NewDecl << OldImportAttr;
6577 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
6581 }
else if (IsInline && OldImportAttr && !IsMicrosoftABI) {
6587 diag::warn_dllimport_dropped_from_inline_function)
6588 << NewDecl << OldImportAttr;
6595 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewDecl)) {
6597 !NewImportAttr && !NewExportAttr) {
6653 return D->isExternC();
6659 isa<OMPDeclareMapperDecl>(DC))
6665 if (isa<RequiresExprBodyDecl>(DC))
6667 llvm_unreachable(
"Unexpected context");
6673 isa<OMPDeclareReductionDecl>(DC) || isa<OMPDeclareMapperDecl>(DC))
6677 llvm_unreachable(
"Unexpected context");
6723 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
6724 return FD->isExternC();
6725 if (
const auto *VD = dyn_cast<VarDecl>(D))
6726 return VD->isExternC();
6728 llvm_unreachable(
"Unknown type of decl!");
6738 diag::err_opencl_type_can_only_be_used_as_function_parameter)
6749 if (
NULL == S->getParent()) {
6752 diag::err_invalid_type_for_program_scope_var)
6800 diag::err_opencl_unknown_type_specifier)
6845 if (!Decomp.bindings().empty()) {
6846 II = Decomp.bindings()[0].Name;
6866 bool IsLocalExternDecl = SC ==
SC_Extern &&
6885 : diag::warn_deprecated_register)
6891 if (!DC->
isRecord() && S->getFnParent() ==
nullptr) {
6907 bool IsMemberSpecialization =
false;
6908 bool IsVariableTemplateSpecialization =
false;
6910 bool IsVariableTemplate =
false;
6929 bool Invalid =
false;
6938 diag::err_static_out_of_line)
6950 diag::err_storage_class_for_static_member)
6954 llvm_unreachable(
"C storage class in c++!");
6959 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
6965 if (Ctxt->isFunctionOrMethod()) {
6966 FunctionOrMethod = Ctxt;
6969 const CXXRecordDecl *ParentDecl = dyn_cast<CXXRecordDecl>(Ctxt);
6971 AnonStruct = ParentDecl;
6975 if (FunctionOrMethod) {
6979 diag::err_static_data_member_not_allowed_in_local_class)
6980 << Name << RD->getDeclName() << RD->getTagKind();
6981 }
else if (AnonStruct) {
6986 diag::err_static_data_member_not_allowed_in_anon_struct)
6989 }
else if (RD->isUnion()) {
6994 ? diag::warn_cxx98_compat_static_data_member_in_union
6995 : diag::ext_static_data_member_in_union) << Name;
7002 bool InvalidScope =
false;
7010 false, IsMemberSpecialization, InvalidScope);
7011 Invalid |= InvalidScope;
7013 if (TemplateParams) {
7014 if (!TemplateParams->
size() &&
7019 diag::err_template_variable_noparams)
7023 TemplateParams =
nullptr;
7031 IsVariableTemplateSpecialization =
true;
7035 IsVariableTemplate =
true;
7040 ? diag::warn_cxx11_compat_variable_template
7041 : diag::ext_variable_template);
7046 if (!TemplateParamLists.empty() && IsMemberSpecialization &&
7051 "should have a 'template<>' for this decl");
7054 if (IsVariableTemplateSpecialization) {
7056 TemplateParamLists.size() > 0
7057 ? TemplateParamLists[0]->getTemplateLoc()
7060 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
7075 if (IsVariableTemplate) {
7078 TemplateParams, NewVD);
7097 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
7098 if (TemplateParamLists.size() > VDTemplateParamLists)
7100 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
7110 diag::err_inline_declaration_block_scope) << Name
7115 : diag::ext_inline_variable);
7126 if (IsLocalExternDecl) {
7128 for (
auto *B : Bindings)
7129 B->setLocalExternDecl();
7134 bool EmitTLSUnsupportedError =
false;
7147 diag::err_thread_non_global)
7155 EmitTLSUnsupportedError =
true;
7162 diag::err_thread_unsupported);
7173 diag::err_constexpr_wrong_decl_kind)
7174 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
7192 diag::err_constinit_local_variable);
7209 if (SC ==
SC_Static && S->getFnParent() !=
nullptr &&
7214 diag::warn_static_local_in_extern_inline);
7220 if (IsVariableTemplateSpecialization)
7225 else if (IsMemberSpecialization)
7239 for (
auto *B : Bindings)
7240 B->setModulePrivate();
7256 if (EmitTLSUnsupportedError &&
7261 diag::err_thread_unsupported);
7263 if (EmitTLSUnsupportedError &&
7268 if (SC ==
SC_None && S->getFnParent() !=
nullptr &&
7292 if (S->getFnParent() !=
nullptr) {
7296 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) <<
Label;
7302 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) <<
Label;
7313 bool HasSizeMismatch;
7315 if (!TI.isValidGCCRegisterName(
Label))
7316 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) <<
Label;
7317 else if (!TI.validateGlobalRegisterVariable(
Label,
7320 Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) <<
Label;
7321 else if (HasSizeMismatch)
7322 Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) <<
Label;
7335 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
7357 IsMemberSpecialization ||
7358 IsVariableTemplateSpecialization);
7379 isa<FieldDecl>(
Previous.getFoundDecl()) &&
7396 if (!IsVariableTemplateSpecialization)
7420 if (PrevVarTemplate &&
7440 Decl *ManglingContextDecl;
7441 std::tie(MCtx, ManglingContextDecl) =
7452 if (Name.getAsIdentifierInfo() && Name.getAsIdentifierInfo()->isStr(
"main") &&
7499 if (isa<TypeAliasDecl>(ShadowedDecl))
7501 else if (isa<TypedefDecl>(ShadowedDecl))
7503 else if (isa<RecordDecl>(OldDC))
7575 if (
FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
7583 if (isa<CXXConstructorDecl>(NewDC))
7584 if (
const auto PVD = dyn_cast<ParmVarDecl>(D)) {
7587 ShadowingDecls.insert({PVD->getCanonicalDecl(), FD});
7592 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
7593 if (shadowedVar->isExternC()) {
7596 for (
auto I : shadowedVar->redecls())
7597 if (I->isFileVarDecl()) {
7605 unsigned WarningDiag = diag::warn_decl_shadow;
7607 if (isa<VarDecl>(D) && isa<VarDecl>(ShadowedDecl) && NewDC &&
7608 isa<CXXMethodDecl>(NewDC)) {
7609 if (
const auto *RD = dyn_cast<CXXRecordDecl>(NewDC->
getParent())) {
7611 if (RD->getLambdaCaptureDefault() ==
LCD_None) {
7617 WarningDiag = diag::warn_decl_shadow_uncaptured_local;
7622 ->ShadowingDecls.push_back(
7628 if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
7632 ParentDC && !ParentDC->
Equals(OldDC);
7636 if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
7668 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7677 const VarDecl *ShadowedDecl = Shadow.ShadowedDecl;
7682 ? diag::warn_decl_shadow_uncaptured_local
7683 : diag::warn_decl_shadow)
7684 << Shadow.VD->getDeclName()
7687 Diag(CaptureLoc, diag::note_var_explicitly_captured_here)
7688 << Shadow.VD->getDeclName() << 0;
7712 auto *DRE = dyn_cast<DeclRefExpr>(E);
7716 auto I = ShadowingDecls.find(D);
7717 if (I == ShadowingDecls.end())
7719 const NamedDecl *ShadowedDecl = I->second;
7721 Diag(Loc, diag::warn_modifying_shadowing_decl) << D << OldDC;
7726 ShadowingDecls.erase(I);
7734 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
7755 if (!isa<VarDecl>(ND))
7765 if (isa<VarDecl>(*I)) {
7775 if (isa<VarDecl>(*I)) {
7793 assert(Prev &&
"should have found a previous declaration to diagnose");
7795 Prev = FD->getFirstDecl();
7799 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
7821 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
7833 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
7854 if (T->isUndeducedType())
7860 if (T->isObjCObjectType()) {
7895 if (T->isBlockPointerType()) {
7898 if (!T.isConstQualified()) {
7899 Diag(NewVD->
getLocation(), diag::err_opencl_invalid_block_declaration)
7905 Diag(NewVD->
getLocation(), diag::err_opencl_extern_block_declaration);
7919 if (!T->isSamplerT() &&
7920 !T->isDependentType() &&
7927 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7928 <<
Scope <<
"global or constant";
7930 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
7931 <<
Scope <<
"constant";
7993 bool isVM = T->isVariablyModifiedType();
8000 bool SizeIsNegative;
8001 llvm::APSInt Oversized;
8006 FixedT = FixedTInfo->
getType();
8007 else if (FixedTInfo) {
8013 if ((!FixedTInfo || FixedT.
isNull()) && T->isVariableArrayType()) {
8046 if (T->isVoidType()) {
8075 if (NewVD->
isConstexpr() && !T->isDependentType() &&
8077 diag::err_constexpr_var_non_literal)) {
8132 CXXRecordDecl *BaseRecord = Specifier->getType()->getAsCXXRecordDecl();
8144 dyn_cast<CXXMethodDecl>(BaseND->getCanonicalDecl());
8153 if (Overridden.insert(BaseMD).second) {
8170 return !Overridden.empty();
8176 struct ActOnFDArgs {
8192 : Context(Context), OriginalFD(TypoFD),
8195 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
8201 CDeclEnd = candidate.
end();
8202 CDecl != CDeclEnd; ++CDecl) {
8209 if (
Parent &&
Parent->getCanonicalDecl() == ExpectedParent)
8211 }
else if (!ExpectedParent) {
8220 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
8221 return std::make_unique<DifferentNameValidatorCCC>(*
this);
8247 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *S) {
8255 IsLocalFriend ? diag::err_no_matching_local_friend :
8257 diag::err_member_decl_does_not_match;
8269 "Cannot have an ambiguity in previous-declaration lookup");
8271 DifferentNameValidatorCCC CCC(SemaRef.
Context, NewFD,
8273 if (!Prev.
empty()) {
8275 Func != FuncEnd; ++Func) {
8282 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
8283 NearMatches.push_back(std::make_pair(FD, ParamNum));
8290 IsLocalFriend ?
nullptr : NewDC))) {
8297 CDeclEnd = Correction.
end();
8298 CDecl != CDeclEnd; ++CDecl) {
8318 ExtraArgs.S, ExtraArgs.D,
8321 ExtraArgs.AddToScope);
8332 if ((*I)->getCanonicalDecl() == Canonical)
8339 SemaRef.
PDiag(IsLocalFriend
8340 ? diag::err_no_matching_local_friend_suggest
8341 : diag::err_member_decl_does_not_match_suggest)
8342 << Name << NewDC << IsDefinition);
8355 << Name << NewDC << IsDefinition << NewFD->
getLocation();
8357 bool NewFDisConst =
false;
8359 NewFDisConst = NewMD->isConst();
8362 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
8363 NearMatch != NearMatchEnd; ++NearMatch) {
8366 bool FDisConst = MD && MD->
isConst();
8367 bool IsMember = MD || !IsLocalFriend;
8370 if (
unsigned Idx = NearMatch->second) {
8374 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
8375 : diag::note_local_decl_close_param_match)
8378 }
else if (FDisConst != NewFDisConst) {
8379 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
8383 IsMember ? diag::note_member_def_close_match
8384 : diag::note_local_decl_close_match);
8391 default: llvm_unreachable(
"Unknown storage class!");
8396 diag::err_typecheck_sclass_func);
8413 diag::err_static_block_func);
8429 bool &IsVirtualOkay) {
8448 R, TInfo, SC, isInline, HasPrototype,
8462 diag::err_constexpr_wrong_decl_kind)
8463 <<
static_cast<int>(ConstexprKind);
8481 "Constructors can only be declared in a member context");
8488 TrailingRequiresClause);
8497 isInline,
false, ConstexprKind,
8498 TrailingRequiresClause);
8506 IsVirtualOkay =
true;
8518 true, ConstexprKind,
8519 TrailingRequiresClause);
8525 diag::err_conv_function_not_member);
8533 IsVirtualOkay =
true;
8537 TrailingRequiresClause);
8540 if (TrailingRequiresClause)
8542 diag::err_trailing_requires_clause_on_deduction_guide)
8554 if (Name.getAsIdentifierInfo() &&
8555 Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
8566 TrailingRequiresClause);
8567 IsVirtualOkay = !
Ret->isStatic();
8579 R, TInfo, SC, isInline,
true ,
8580 ConstexprKind, TrailingRequiresClause);
8597 StringRef SizeTypeNames[] = {
"size_t",
"intptr_t",
"uintptr_t",
"ptrdiff_t"};
8605 if (Names.end() != Match)
8610 }
while (DesugaredTy != Ty);
8675 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
8690 S.
Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
8703 S.
Diag(Param->getLocation(), diag::err_kernel_arg_address_space);
8720 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
8728 S.
Diag(Loc, diag::note_entity_declared_at) << PT;
8729 PT = Typedef->desugar();
8751 HistoryStack.push_back(
nullptr);
8760 VisitStack.push_back(RecTy->
getDecl());
8761 assert(VisitStack.back() &&
"First decl null?");
8764 const Decl *
Next = VisitStack.pop_back_val();
8766 assert(!HistoryStack.empty());
8768 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
8769 ValidTypes.insert(Hist->getType().getTypePtr());
8778 HistoryStack.push_back(Field);
8780 QualType FieldTy = Field->getType();
8784 "Unexpected type.");
8793 VisitStack.push_back(
nullptr);
8795 for (
const auto *FD : RD->
fields()) {
8806 VisitStack.push_back(FD);
8816 S.
Diag(Param->getLocation(),
8817 diag::err_record_with_pointers_kernel_param)
8821 S.
Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
8824 S.
Diag(OrigRecDecl->getLocation(), diag::note_within_field_of_type)
8825 << OrigRecDecl->getDeclName();
8830 I = HistoryStack.begin() + 1,
8831 E = HistoryStack.end();
8844 }
while (!VisitStack.empty());
8860 while (S->isClassScope() ||
8861 (LangOpts.CPlusPlus &&
8862 S->isFunctionPrototypeScope()) ||
8864 (S->getEntity() && S->getEntity()->isTransparentContext()))
8882 TemplateParamLists.push_back(TPL);
8884 if (!TemplateParamLists.empty() &&
8885 Invented->getDepth() == TemplateParamLists.back()->getDepth())
8886 TemplateParamLists.back() = Invented;
8888 TemplateParamLists.push_back(Invented);
8898 diag::err_invalid_thread)
8905 bool isFriend =
false;
8907 bool isMemberSpecialization =
false;
8908 bool isFunctionTemplateSpecialization =
false;
8910 bool isDependentClassScopeExplicitSpecialization =
false;
8911 bool HasExplicitTemplateArgs =
false;
8914 bool isVirtualOkay =
false;
8921 if (!NewFD)
return nullptr;
8931 if (IsLocalExternDecl)
8951 if (
Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
8956 if (isVirtual &&
Parent->isUnion())
8961 isMemberSpecialization =
false;
8962 isFunctionTemplateSpecialization =
false;
8968 bool Invalid =
false;
8976 TemplateParamLists, isFriend, isMemberSpecialization,
8978 if (TemplateParams) {
8983 if (TemplateParams->
size() > 0) {
9003 Name, TemplateParams,
9009 if (TemplateParamLists.size() > 1) {
9016 isFunctionTemplateSpecialization =
true;
9018 if (TemplateParamLists.size() > 0)
9038 << Name << RemoveRange
9045 if (!TemplateParamLists.empty() && isMemberSpecialization &&
9051 if (TemplateParamLists.size() > 0)
9068 if (!isVirtualOkay) {
9070 diag::err_virtual_non_function);
9074 diag::err_virtual_out_of_class)
9080 diag::err_virtual_member_function_template)
9117 diag::err_inline_declaration_block_scope) << Name
9127 !isa<CXXDeductionGuideDecl>(NewFD)) {
9131 diag::err_explicit_out_of_class)
9133 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
9134 !isa<CXXConversionDecl>(NewFD)) {
9138 diag::err_explicit_non_ctor_or_conv_function)
9152 if (isa<CXXDestructorDecl>(NewFD) &&
9156 <<
static_cast<int>(ConstexprKind);
9170 diag::err_invalid_consteval_decl_kind)
9178 if (isFunctionTemplateSpecialization) {
9181 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
9216 if (isa<CXXMethodDecl>(NewFD) && DC ==
CurContext &&
9224 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
9239 cast<CXXRecordDecl>(DC)->getDescribedClassTemplate()) ||
9241 ? diag::ext_static_out_of_line : diag::err_static_out_of_line)
9249 if ((Name.getCXXOverloadedOperator() == OO_Delete ||
9250 Name.getCXXOverloadedOperator() == OO_Array_Delete) &&
9260 isMemberSpecialization ||
9261 isFunctionTemplateSpecialization);
9271 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
9296 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
9298 assert(Param->getDeclContext() != NewFD &&
"Was set before ?");
9299 Param->setDeclContext(NewFD);
9300 Params.push_back(Param);
9302 if (Param->isInvalidDecl())
9315 auto *TD = dyn_cast<TagDecl>(NonParmDecl);
9320 if (
auto *ECD = dyn_cast<EnumConstantDecl>(NonParmDecl))
9329 TD->setDeclContext(NewFD);
9337 if (TagDC != PrototypeTagContext)
9338 TD->setLexicalDeclContext(TagDC);
9352 for (
const auto &AI : FT->param_types()) {
9355 Param->setScopeInfo(0, Params.size());
9356 Params.push_back(Param);
9360 "Should not need args for typedef of non-prototype fn");
9364 NewFD->setParams(Params);
9418 diag::err_opencl_return_value_with_address_space);
9436 isMemberSpecialization));
9442 "previous declaration set still overloaded");
9454 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
9477 diag::ext_operator_new_delete_declared_inline)
9491 HasExplicitTemplateArgs =
true;
9494 HasExplicitTemplateArgs =
false;
9500 HasExplicitTemplateArgs =
false;
9502 assert((isFunctionTemplateSpecialization ||
9504 "should have a 'template<>' for this decl");
9506 isFunctionTemplateSpecialization =
true;
9508 }
else if (isFriend && isFunctionTemplateSpecialization) {
9515 HasExplicitTemplateArgs =
true;
9533 if (isFunctionTemplateSpecialization && isFriend &&
9537 assert(HasExplicitTemplateArgs &&
9538 "friend function specialization without template args");
9542 }
else if (isFunctionTemplateSpecialization) {
9545 isDependentClassScopeExplicitSpecialization =
true;
9548 NewFD, (HasExplicitTemplateArgs ? &TemplateArgs :
nullptr),
9560 diag::err_explicit_specialization_inconsistent_storage_class)
9567 diag::ext_explicit_specialization_storage_class)
9571 }
else if (isMemberSpecialization && isa<CXXMethodDecl>(NewFD)) {
9577 if (!isDependentClassScopeExplicitSpecialization) {
9586 isMemberSpecialization));
9594 "previous declaration set still overloaded");
9635 struct ActOnFDArgs ExtraArgs = { S, D, TemplateParamLists,
9677 *
this,
Previous, NewFD, ExtraArgs,
false,
nullptr)) {
9678 AddToScope = ExtraArgs.AddToScope;
9685 }
else if (isFriend && cast<CXXRecordDecl>(
CurContext)->isLocalClass()) {
9687 *
this,
Previous, NewFD, ExtraArgs,
true, S)) {
9688 AddToScope = ExtraArgs.AddToScope;
9693 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
9694 !isFriend && !isFunctionTemplateSpecialization &&
9695 !isMemberSpecialization) {
9713 if (
unsigned BuiltinID = II->getBuiltinID()) {
9729 }
else if (BuiltinID == Builtin::BI__GetExceptionInfo &&
9746 diag::err_attribute_overloadable_no_prototype)
9753 EPI.Variadic =
true;
9786 isMemberSpecialization ||
9787 isFunctionTemplateSpecialization,
9869 QualType ElemTy = PipeTy->getElementType();
9871 Diag(Param->getTypeSpecStartLoc(), diag::err_reference_pipe_type );
9881 if (isDependentClassScopeExplicitSpecialization) {
9885 cast<CXXMethodDecl>(NewFD),
9886 HasExplicitTemplateArgs, TemplateArgs);
9895 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9900 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
9917 Diag(NBA->getLocation(),
9918 diag::err_attribute_no_builtin_on_defaulted_deleted_function)
9919 << NBA->getSpelling();
9922 Diag(NBA->getLocation(), diag::err_attribute_no_builtin_on_non_definition)
9923 << NBA->getSpelling();
9943 const auto *Method = dyn_cast<CXXMethodDecl>(FD);
9958 while ((
Parent = dyn_cast<CXXRecordDecl>(
Parent->getParent()))) {
9978 bool IsDefinition) {
10051 auto *VD = dyn_cast<ValueDecl>(D);
10052 auto *PrevVD = dyn_cast<ValueDecl>(PrevDecl);
10053 return !VD || !PrevVD ||
10055 PrevVD->getType());
10064 assert(TA &&
"MultiVersion Candidate requires a target attribute");
10067 enum ErrType { Feature = 0, Architecture = 1 };
10076 for (
const auto &Feat : ParseInfo.
Features) {
10077 auto BareFeat = StringRef{Feat}.substr(1);
10078 if (Feat[0] ==
'-') {
10080 << Feature << (
"no-" + BareFeat).str();
10087 << Feature << BareFeat;
10105 case attr::NonNull:
10106 case attr::NoThrow:
10115 bool IsCPUSpecificCPUDispatchMVType =
10118 const auto Diagnose = [FD, CausedFD, IsCPUSpecificCPUDispatchMVType](
10120 S.
Diag(FD->
getLocation(), diag::err_multiversion_disallowed_other_attr)
10121 << IsCPUSpecificCPUDispatchMVType << A;
10123 S.
Diag(CausedFD->
getLocation(), diag::note_multiversioning_caused_here);
10128 switch (A->getKind()) {
10129 case attr::CPUDispatch:
10130 case attr::CPUSpecific:
10133 return Diagnose(S, A);
10137 return Diagnose(S, A);
10141 return Diagnose(S, A);
10154 bool ConstexprSupported,
bool CLinkageMayDiffer) {
10155 enum DoesntSupport {
10162 DefaultedFuncs = 6,
10163 ConstexprFuncs = 7,
10164 ConstevalFuncs = 8,
10175 if (NoProtoDiagID.
getDiagID() != 0 && OldFD &&
10178 Diag(NoteCausedDiagIDAt.first, NoteCausedDiagIDAt.second);
10186 if (!TemplatesSupported &&
10188 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10191 if (
const auto *NewCXXFD = dyn_cast<CXXMethodDecl>(NewFD)) {
10192 if (NewCXXFD->isVirtual())
10193 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10196 if (isa<CXXConstructorDecl>(NewCXXFD))
10197 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10200 if (isa<CXXDestructorDecl>(NewCXXFD))
10201 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10206 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10210 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10214 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10215 << (NewFD->
isConsteval() ? ConstevalFuncs : ConstexprFuncs);
10219 QualType NewReturnType = NewType->getReturnType();
10222 return Diag(NoSupportDiagIDAt.first, NoSupportDiagIDAt.second)
10232 if (OldTypeInfo.
getCC() != NewTypeInfo.
getCC())
10235 QualType OldReturnType = OldType->getReturnType();
10237 if (OldReturnType != NewReturnType)
10238 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ReturnType;
10241 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << ConstexprSpec;
10244 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) << InlineSpec;
10250 return Diag(DiffDiagIDAt.first, DiffDiagIDAt.second) <<
Linkage;
10271 bool IsCPUSpecificCPUDispatchMVType =
10275 if (CausesMV && OldFD &&
10283 if (OldFD && CausesMV && OldFD->
isUsed(
false))
10284 return S.
Diag(NewFD->
getLocation(), diag::err_multiversion_after_used);
10287 OldFD, NewFD, S.
PDiag(diag::err_multiversion_noproto),
10289 S.
PDiag(diag::note_multiversioning_caused_here)),
10291 S.
PDiag(diag::err_multiversion_doesnt_support)
10292 << IsCPUSpecificCPUDispatchMVType),
10294 S.
PDiag(diag::err_multiversion_diff)),
10296 !IsCPUSpecificCPUDispatchMVType,
10310 "Function lacks multiversion attribute");
10342 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
10347 llvm::sort(NewParsed.Features);
10376 Redeclaration =
true;
10384 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
10391 if (OldParsed == NewParsed) {
10398 for (
const auto *FD : OldFD->
redecls()) {
10403 (!CurTA || CurTA->isInherited())) {
10406 S.
Diag(NewFD->
getLocation(), diag::note_multiversioning_caused_here);
10414 Redeclaration =
false;
10415 MergeTypeWithPrevious =
false;
10427 bool &Redeclaration,
NamedDecl *&OldDecl,
bool &MergeTypeWithPrevious,
10444 NewParsed = NewTA->
parse();
10448 bool UseMemberUsingDeclRules =
10457 if (S.
IsOverload(NewFD, CurFD, UseMemberUsingDeclRules))
10464 Redeclaration =
true;
10470 if (CurParsed == NewParsed) {
10489 return Cur->getName() == New->getName();
10492 Redeclaration =
true;
10505 if (CurCPUSpec->cpus_size() == NewCPUSpec->
cpus_size() &&
10507 CurCPUSpec->cpus_begin(), CurCPUSpec->cpus_end(),
10510 return Cur->getName() == New->getName();
10513 Redeclaration =
true;
10521 if (CurII == NewII) {
10555 Redeclaration =
true;
10561 Redeclaration =
false;
10562 MergeTypeWithPrevious =
false;
10576 bool &Redeclaration,
NamedDecl *&OldDecl,
10577 bool &MergeTypeWithPrevious,
10584 if ((NewTA && NewCPUDisp) || (NewTA && NewCPUSpec) ||
10585 (NewCPUDisp && NewCPUSpec)) {
10599 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_not_allowed_on_main);
10622 S.
Diag(NewFD->
getLocation(), diag::err_multiversion_required_in_redecl)
10631 Redeclaration, OldDecl,
10638 S, OldFD, NewFD, MVType, NewTA, NewCPUDisp, NewCPUSpec, Redeclaration,
10639 OldDecl, MergeTypeWithPrevious,
Previous);
10661 bool IsMemberSpecialization) {
10663 "Variably modified return types are not handled here");
10668 bool MergeTypeWithPrevious = !
getLangOpts().CPlusPlus &&
10671 bool Redeclaration =
false;
10673 bool MayNeedOverloadableChecks =
false;
10684 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
10685 Redeclaration =
true;
10686 OldDecl = Candidate;
10689 MayNeedOverloadableChecks =
true;
10693 Redeclaration =
true;
10697 Redeclaration =
true;
10701 Redeclaration =
false;
10708 if (!Redeclaration &&
10713 Redeclaration =
true;
10714 OldDecl =
Previous.getFoundDecl();
10715 MergeTypeWithPrevious =
false;
10720 if (
IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
10721 MayNeedOverloadableChecks =
true;
10722 Redeclaration =
false;
10731 return Redeclaration;
10750 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
10754 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
10755 if (!OldMD || !OldMD->
isStatic()) {
10777 if (Redeclaration) {
10782 return Redeclaration;
10789 dyn_cast<FunctionTemplateDecl>(OldDecl)) {
10790 auto *OldFD = OldTemplateDecl->getTemplatedDecl();
10793 assert(NewTemplateDecl &&
"Template/non-template mismatch");
10802 NewFD->
setAccess(OldTemplateDecl->getAccess());
10803 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
10808 if (IsMemberSpecialization &&
10811 assert(OldTemplateDecl->isMemberSpecialization());
10814 if (OldFD->isDeleted()) {
10816 assert(OldFD->getCanonicalDecl() == OldFD);
10818 OldFD->setDeletedAsWritten(
false);
10836 return ND->hasAttr<OverloadableAttr>();
10838 "Non-redecls shouldn't happen without overloadable present");
10841 const auto *FD = dyn_cast<FunctionDecl>(ND);
10845 if (OtherUnmarkedIter !=
Previous.end()) {
10847 diag::err_attribute_overloadable_multiple_unmarked_overloads);
10848 Diag((*OtherUnmarkedIter)->getLocation(),
10849 diag::note_attribute_overloadable_prev_overload)
10866 dyn_cast<CXXDestructorDecl>(NewFD)) {
10879 return Redeclaration;
10882 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(NewFD)) {
10883 if (
auto *TD = Guide->getDescribedFunctionTemplate())
10889 Diag(Guide->getBeginLoc(), diag::err_deduction_guide_specialized)
10894 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
10895 if (!Method->isFunctionTemplateSpecialization() &&
10896 !Method->getDescribedFunctionTemplate() &&
10897 Method->isCanonicalDecl()) {
10904 diag::err_constrained_virtual_method);
10906 if (Method->isStatic())
10917 return Redeclaration;
10924 return Redeclaration;
10962 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
10975 auto HasNoexcept = [&](
QualType T) ->
bool {
10980 T = RT->getPointeeType();
10981 else if (T->isAnyPointerType())
10982 T = T->getPointeeType();
10984 T = MPT->getPointeeType();
10986 if (FPT->isNothrow())
10992 bool AnyNoexcept = HasNoexcept(FPT->getReturnType());
10993 for (
QualType T : FPT->param_types())
10994 AnyNoexcept |= HasNoexcept(T);
10997 diag::warn_cxx17_compat_exception_spec_in_signature)
11001 if (!Redeclaration &&
LangOpts.CUDA)
11004 return Redeclaration;
11017 ? diag::err_static_main : diag::warn_static_main)
11025 Diag(NoreturnLoc, diag::ext_noreturn_main);
11026 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
11044 assert(T->isFunctionType() &&
"function decl is not of function type");
11066 Diag(RTRange.
getBegin(), diag::note_main_change_return_type)
11088 if (isa<FunctionNoProtoType>(FT))
return;
11094 bool HasExtraParameters = (nparams > 3);
11106 HasExtraParameters =
false;
11108 if (HasExtraParameters) {
11121 for (
unsigned i = 0; i < nparams; ++i) {
11124 bool mismatch =
true;
11141 mismatch = !qs.
empty();
11164 assert(T->isFunctionType() &&
"function decl is not of function type");
11173 if (FD->
getName() !=
"DllMain")
11192 if (Init->isValueDependent()) {
11193 assert(Init->containsErrors() &&
11194 "Dependent code should only occur in error-recovery path.");
11197 const Expr *Culprit;
11198 if (Init->isConstantInitializer(
Context,
false, &Culprit))
11200 Diag(Culprit->
getExprLoc(), diag::err_init_element_not_constant)
11208 class SelfReferenceChecker
11214 bool isReferenceType;
11222 SelfReferenceChecker(
Sema &S,
Decl *OrigDecl) : Inherited(S.Context),
11223 S(S), OrigDecl(OrigDecl) {
11226 isReferenceType =
false;
11227 isInitList =
false;
11228 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
11229 isPODType = VD->getType().isPODType(S.
Context);
11231 isReferenceType = VD->getType()->isReferenceType();
11238 void CheckExpr(
Expr *E) {
11247 InitFieldIndex.push_back(0);
11248 for (
auto Child : InitList->
children()) {
11249 CheckExpr(cast<Expr>(Child));
11250 ++InitFieldIndex.back();
11252 InitFieldIndex.pop_back();
11257 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
11260 bool ReferenceField =
false;
11264 FieldDecl *FD = dyn_cast<FieldDecl>(ME->getMemberDecl());
11267 Fields.push_back(FD);
11269 ReferenceField =
true;
11270 Base = ME->getBase()->IgnoreParenImpCasts();
11275 if (!DRE || DRE->
getDecl() != OrigDecl)
11279 if (CheckReference && !ReferenceField)
11284 for (
const FieldDecl *I : llvm::reverse(Fields))
11285 UsedFieldIndex.push_back(I->getFieldIndex());
11290 for (
auto UsedIter = UsedFieldIndex.begin(),
11291 UsedEnd = UsedFieldIndex.end(),
11292 OrigIter = InitFieldIndex.begin(),
11293 OrigEnd = InitFieldIndex.end();
11294 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
11295 if (*UsedIter < *OrigIter)
11297 if (*UsedIter > *OrigIter)
11302 HandleDeclRefExpr(DRE);
11309 void HandleValue(
Expr *E) {
11311 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
11312 HandleDeclRefExpr(DRE);
11317 Visit(CO->getCond());
11318 HandleValue(CO->getTrueExpr());
11319 HandleValue(CO->getFalseExpr());
11324 dyn_cast<BinaryConditionalOperator>(E)) {
11325 Visit(BCO->getCond());
11326 HandleValue(BCO->getFalseExpr());
11331 HandleValue(OVE->getSourceExpr());
11336 if (BO->getOpcode() == BO_Comma) {
11337 Visit(BO->getLHS());
11338 HandleValue(BO->getRHS());
11343 if (isa<MemberExpr>(E)) {
11345 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
11353 if (!isa<FieldDecl>(ME->getMemberDecl()))
11355 Base = ME->getBase()->IgnoreParenImpCasts();
11358 HandleDeclRefExpr(DRE);
11368 if (isReferenceType)
11369 HandleDeclRefExpr(E);
11378 Inherited::VisitImplicitCastExpr(E);
11383 if (CheckInitListMemberExpr(E,
true ))
11393 bool Warn = (MD && !MD->
isStatic());
11396 if (!isa<FieldDecl>(ME->getMemberDecl()))
11398 Base = ME->getBase()->IgnoreParenImpCasts();
11403 HandleDeclRefExpr(DRE);
11415 if (isa<UnresolvedLookupExpr>(Callee))
11416 return Inherited::VisitCXXOperatorCallExpr(E);
11420 HandleValue(Arg->IgnoreParenImpCasts());
11437 Inherited::VisitUnaryOperator(E);
11445 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
11446 if (ILE->getNumInits() == 1)
11447 ArgExpr = ILE->getInit(0);
11449 if (ICE->getCastKind() == CK_NoOp)
11450 ArgExpr = ICE->getSubExpr();
11451 HandleValue(ArgExpr);
11454 Inherited::VisitCXXConstructExpr(E);
11460 HandleValue(E->
getArg(0));
11464 Inherited::VisitCallExpr(E);
11469 HandleValue(E->
getLHS());
11474 Inherited::VisitBinaryOperator(E);
11487 if (OrigDecl != ReferenceDecl)
return;
11489 if (isReferenceType) {
11490 diag = diag::warn_uninit_self_reference_in_reference_init;
11491 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
11492 diag = diag::warn_static_self_reference_in_init;
11493 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
11496 diag = diag::warn_uninit_self_reference_in_init;
11510 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
11514 if (isa<ParmVarDecl>(OrigDecl))
11523 if (ICE->getCastKind() == CK_LValueToRValue)
11524 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
11525 if (DRE->
getDecl() == OrigDecl)
11528 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
11535 struct VarDeclOrName {
11541 return VN.VDecl ?
Diag << VN.VDecl :
Diag << VN.Name;
11551 bool IsInitCapture = !VDecl;
11553 "init captures are expected to be deduced prior to initialization");
11555 VarDeclOrName VN{VDecl, Name};
11558 assert(Deduced &&
"deduceVarTypeFromInitializer for non-deduced type");
11562 assert(VDecl &&
"no init for init capture deduction?");
11566 if (!isa<DeducedTemplateSpecializationType>(Deduced) ||
11577 DeduceInits = Init;
11580 if (
auto *PL = dyn_cast_or_null<ParenListExpr>(Init))
11581 DeduceInits = PL->exprs();
11584 if (isa<DeducedTemplateSpecializationType>(Deduced)) {
11585 assert(VDecl &&
"non-auto type for init capture deduction?");
11596 if (
auto *IL = dyn_cast<InitListExpr>(Init))
11597 DeduceInits = IL->inits();
11601 if (DeduceInits.empty()) {
11604 Diag(Init->getBeginLoc(), IsInitCapture
11605 ? diag::err_init_capture_no_expression
11606 : diag::err_auto_var_init_no_expression)
11607 << VN <<
Type << Range;
11611 if (DeduceInits.size() > 1) {
11612 Diag(DeduceInits[1]->getBeginLoc(),
11613 IsInitCapture ? diag::err_init_capture_multiple_expressions
11614 : diag::err_auto_var_init_multiple_expressions)
11615 << VN <<
Type << Range;
11619 Expr *DeduceInit = DeduceInits[0];
11620 if (
DirectInit && isa<InitListExpr>(DeduceInit)) {
11621 Diag(Init->getBeginLoc(), IsInitCapture
11622 ? diag::err_init_capture_paren_braces
11623 : diag::err_auto_var_init_paren_braces)
11629 bool DefaultedAnyToId =
false;
11633 if (
Result.isInvalid()) {
11637 DefaultedAnyToId =
true;
11643 if (VDecl && isa<DecompositionDecl>(VDecl) &&
11647 Type.getQualifiers());
11651 if (!IsInitCapture)
11653 else if (isa<InitListExpr>(Init))
11654 Diag(Range.getBegin(),
11655 diag::err_init_capture_deduction_failure_from_init_list)
11661 Diag(Range.getBegin(), diag::err_init_capture_deduction_failure)
11676 Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
11684 assert(!Init || !Init->containsErrors());
11718 if (
auto *EWC = dyn_cast<ExprWithCleanups>(Init))
11719 Init = EWC->getSubExpr();
11721 if (
auto *CE = dyn_cast<ConstantExpr>(Init))
11722 Init = CE->getSubExpr();
11724 QualType InitType = Init->getType();
11727 "shouldn't be called if type doesn't have a non-trivial C struct");
11728 if (
auto *ILE = dyn_cast<InitListExpr>(Init)) {
11729 for (
auto I : ILE->inits()) {
11730 if (!I->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion() &&
11731 !I->getType().hasNonTrivialToPrimitiveCopyCUnion())
11739 if (isa<ImplicitValueInitExpr>(Init)) {
11755bool shouldIgnoreForRecordTriviality(
const FieldDecl *FD) {
11764struct DiagNonTrivalCUnionDefaultInitializeVisitor
11771 DiagNonTrivalCUnionDefaultInitializeVisitor(
11774 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11777 const FieldDecl *FD,
bool InNonTrivialUnion) {
11780 InNonTrivialUnion);
11781 return Super::visitWithKind(PDIK, QT, FD, InNonTrivialUnion);
11785 bool InNonTrivialUnion) {
11786 if (InNonTrivialUnion)
11788 << 1 << 0 << QT << FD->
getName();
11792 if (InNonTrivialUnion)
11794 << 1 << 0 << QT << FD->
getName();
11800 if (OrigLoc.isValid()) {
11801 bool IsUnion =
false;
11802 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
11803 IsUnion = OrigRD->isUnion();
11804 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11805 << 0 << OrigTy << IsUnion << UseContext;
11809 InNonTrivialUnion =
true;
11812 if (InNonTrivialUnion)
11817 if (!shouldIgnoreForRecordTriviality(FD))
11818 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11831struct DiagNonTrivalCUnionDestructedTypeVisitor
11836 DiagNonTrivalCUnionDestructedTypeVisitor(
11839 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11842 const FieldDecl *FD,
bool InNonTrivialUnion) {
11845 InNonTrivialUnion);
11846 return Super::visitWithKind(DK, QT, FD, InNonTrivialUnion);
11850 bool InNonTrivialUnion) {
11851 if (InNonTrivialUnion)
11853 << 1 << 1 << QT << FD->
getName();
11857 if (InNonTrivialUnion)
11859 << 1 << 1 << QT << FD->
getName();
11865 if (OrigLoc.isValid()) {
11866 bool IsUnion =
false;
11867 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
11868 IsUnion = OrigRD->isUnion();
11869 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11870 << 1 << OrigTy << IsUnion << UseContext;
11874 InNonTrivialUnion =
true;
11877 if (InNonTrivialUnion)
11882 if (!shouldIgnoreForRecordTriviality(FD))
11883 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11888 bool InNonTrivialUnion) {}
11898struct DiagNonTrivalCUnionCopyVisitor
11905 : OrigTy(OrigTy), OrigLoc(OrigLoc), UseContext(UseContext), S(S) {}
11908 const FieldDecl *FD,
bool InNonTrivialUnion) {
11911 InNonTrivialUnion);
11912 return Super::visitWithKind(PCK, QT, FD, InNonTrivialUnion);
11916 bool InNonTrivialUnion) {
11917 if (InNonTrivialUnion)
11919 << 1 << 2 << QT << FD->
getName();
11923 if (InNonTrivialUnion)
11925 << 1 << 2 << QT << FD->
getName();
11931 if (OrigLoc.isValid()) {
11932 bool IsUnion =
false;
11933 if (
auto *OrigRD = OrigTy->getAsRecordDecl())
11934 IsUnion = OrigRD->isUnion();
11935 S.
Diag(OrigLoc, diag::err_non_trivial_c_union_in_invalid_context)
11936 << 2 << OrigTy << IsUnion << UseContext;
11940 InNonTrivialUnion =
true;
11943 if (InNonTrivialUnion)
11948 if (!shouldIgnoreForRecordTriviality(FD))
11949 asDerived().visit(FD->
getType(), FD, InNonTrivialUnion);
11953 const FieldDecl *FD,
bool InNonTrivialUnion) {}
11956 bool InNonTrivialUnion) {}
11970 unsigned NonTrivialKind) {
11974 "shouldn't be called if type doesn't have a non-trivial C union");
11978 DiagNonTrivalCUnionDefaultInitializeVisitor(QT, Loc, UseContext, *
this)
11979 .visit(QT,
nullptr,
false);
11982 DiagNonTrivalCUnionDestructedTypeVisitor(QT, Loc, UseContext, *
this)
11983 .visit(QT,
nullptr,
false);
11985 DiagNonTrivalCUnionCopyVisitor(QT, Loc, UseContext, *
this)
11986 .visit(QT,
nullptr,
false);
12000 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
12002 Diag(Method->getLocation(), diag::err_member_function_initialization)
12003 << Method->getDeclName() << Init->getSourceRange();
12004 Method->setInvalidDecl();
12008 VarDecl *VDecl = dyn_cast<VarDecl>(RealDecl);
12010 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
12042 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
12060 BaseDeclType = Array->getElementType();
12062 diag::err_typecheck_decl_incomplete_type)) {
12069 diag::err_abstract_type_in_decl,
12098 Diag(Init->getExprLoc(), diag::err_static_data_member_reinitialization)
12101 diag::note_previous_initializer)
12125 Diag(VDecl->
getLocation(), diag::err_loader_uninitialized_cant_init);
12139 if (
Result.isInvalid()) {
12147 ParenListExpr *CXXDirectInit = dyn_cast<ParenListExpr>(Init);
12159 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
12161 Args[Idx], VDecl,
true,
12162 [
this, Entity, Kind](
Expr *E) {
12164 return Init.Failed() ?
ExprError() : E;
12168 }
else if (Res.
get() != Args[Idx]) {
12169 Args[Idx] = Res.
get();
12179 if (
Result.isInvalid()) {
12199 CheckSelfReference(*
this, RealDecl, Init,
DirectInit);
12227 Init->getBeginLoc()))
12228 FSI->markSafeWeakUse(Init);
12245 if (
Result.isInvalid()) {
12278 isa<InitListExpr>(Init)) {
12279 const Expr *Culprit;
12280 if (!Init->isConstantInitializer(
Context,
false, &Culprit)) {
12282 diag::ext_aggregate_init_not_constant)
12287 if (
auto *E = dyn_cast<ExprWithCleanups>(Init))
12288 if (
auto *BE = dyn_cast<BlockExpr>(E->getSubExpr()->
IgnoreParens()))
12290 BE->getBlockDecl()->setCanAvoidCopyToHeap();
12325 << Init->getSourceRange();
12336 else if (Init->isValueDependent())
12338 else if (Init->isIntegerConstantExpr(
Context, &Loc))
12340 else if (Init->getType()->isScopedEnumeralType() &&
12341 Init->isCXX11ConstantExpr(
Context))
12343 else if (Init->isEvaluatable(
Context)) {
12346 Diag(Loc, diag::ext_in_class_initializer_non_constant)
12347 << Init->getSourceRange();
12351 Diag(Loc, diag::err_in_class_initializer_non_constant)
12352 << Init->getSourceRange();
12362 diag::ext_in_class_initializer_float_type_cxx11)
12363 << DclT << Init->getSourceRange();
12365 diag::note_in_class_initializer_float_type_cxx11)
12368 Diag(VDecl->
getLocation(), diag::ext_in_class_initializer_float_type)
12369 << DclT << Init->getSourceRange();
12371 if (!Init->isValueDependent() && !Init->isEvaluatable(
Context)) {
12372 Diag(Init->getExprLoc(), diag::err_in_class_initializer_non_constant)
12373 << Init->getSourceRange();
12380 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
12381 << DclT << Init->getSourceRange()
12387 << DclT << Init->getSourceRange();
12418 QualType InitType = Init->getType();
12419 if (!InitType.
isNull() &&
12438 if (CXXDirectInit) {
12439 assert(
DirectInit &&
"Call-style initializer must be direct init.");
12447 DeclsToCheckForDeferredDiags.push_back(VDecl);
12459 VarDecl *VD = dyn_cast<VarDecl>(D);
12463 if (
auto *DD = dyn_cast<DecompositionDecl>(D))
12464 for (
auto *BD : DD->bindings())
12465 BD->setInvalidDecl();
12479 diag::err_typecheck_decl_incomplete_type)) {
12486 diag::err_abstract_type_in_decl,
12501 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
12505 if (isa<DecompositionDecl>(RealDecl)) {
12506 Diag(Var->getLocation(), diag::err_decomp_decl_requires_init) << Var;
12507 Var->setInvalidDecl();
12521 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
12522 !Var->isThisDeclarationADemotedDefinition()) {
12523 if (Var->isStaticDataMember()) {
12528 Diag(Var->getLocation(),
12529 diag::err_constexpr_static_mem_var_requires_init)
12531 Var->setInvalidDecl();
12535 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
12536 Var->setInvalidDecl();
12543 if (!Var->isInvalidDecl() &&
12545 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
12546 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
12547 Var->setInvalidDecl();
12552 if (Var->getStorageClass() ==
SC_Extern) {
12553 Diag(Var->getLocation(), diag::err_loader_uninitialized_extern_decl)
12555 Var->setInvalidDecl();
12559 diag::err_typecheck_decl_incomplete_type)) {
12560 Var->setInvalidDecl();
12563 if (
CXXRecordDecl *RD = Var->getType()->getAsCXXRecordDecl()) {
12564 if (!RD->hasTrivialDefaultConstructor()) {
12565 Diag(Var->getLocation(), diag::err_loader_uninitialized_trivial_ctor);
12566 Var->setInvalidDecl();
12574 Var->getType().hasNonTrivialToPrimitiveDefaultInitializeCUnion())
12581 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
12597 !Var->hasLinkage() && !Var->isInvalidDecl() &&
12599 diag::err_typecheck_decl_incomplete_type))
12600 Var->setInvalidDecl();
12605 diag::err_abstract_type_in_decl,
12607 Var->setInvalidDecl();
12610 Diag(Var->getLocation(), diag::warn_private_extern);
12611 Diag(Var->getLocation(), diag::note_private_extern);
12626 if (!Var->isInvalidDecl()) {
12630 Var->getLocation(), ArrayT->getElementType(),
12631 diag::err_array_incomplete_or_sizeless_type))
12632 Var->setInvalidDecl();
12633 }
else if (Var->getStorageClass() ==
SC_Static) {
12643 if (Var->isFirstDecl())
12645 diag::ext_typecheck_decl_incomplete_type);
12650 if (!Var->isInvalidDecl())
12658 Diag(Var->getLocation(),
12659 diag::err_typecheck_incomplete_array_needs_initializer);
12660 Var->setInvalidDecl();
12667 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
12668 << Var <<
SourceRange(Var->getLocation(), Var->getLocation());
12669 Var->setInvalidDecl();
12678 if (Var->isInvalidDecl())
12684 diag::err_typecheck_decl_incomplete_type)) {
12685 Var->setInvalidDecl();
12694 diag::err_abstract_type_in_decl,
12696 Var->setInvalidDecl();
12717 if (!CXXRecord->isPOD())
12751 }
else if (Init.isInvalid()) {
12769 VarDecl *VD = dyn_cast<VarDecl>(D);
12830 const char *PrevSpec;
12845 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
12893 !isa<VarTemplatePartialSpecializationDecl>(var) &&
12895 !
getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
12903 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
12911 const Expr *CacheCulprit =
nullptr;
12912 auto checkConstInit = [&]()
mutable {
12913 if (!CacheHasConstInit)
12916 return *CacheHasConstInit;
12928 if (!checkConstInit()) {
12960 }
else if (Stack->CurrentValue) {
12962 auto SectionName = Stack->CurrentValue->getString();
12964 Context, SectionName, Stack->CurrentPragmaLocation,
12980 isa<InitListExpr>(var->
getInit())) {
12982 unsigned NumInits = ILE->getNumInits();
12984 for (
unsigned I = 0; I < NumInits; ++I) {
12985 const auto *Init = ILE->getInit(I);
12988 const auto *SL = dyn_cast<StringLiteral>(Init->IgnoreImpCasts());
12992 unsigned NumConcat = SL->getNumConcatenated();
12996 if (NumConcat == 2 && !SL->getBeginLoc().isMacroID()) {
12997 bool OnlyOneMissingComma =
true;
12998 for (
unsigned J = I + 1; J < NumInits; ++J) {
12999 const auto *Init = ILE->getInit(J);
13002 const auto *SLJ = dyn_cast<StringLiteral>(Init->IgnoreImpCasts());
13003 if (!SLJ || SLJ->getNumConcatenated() > 1) {
13004 OnlyOneMissingComma =
false;
13009 if (OnlyOneMissingComma) {
13011 for (
unsigned i = 0; i < NumConcat - 1; ++i)
13015 Diag(SL->getStrTokenLoc(1),
13016 diag::warn_concatenated_literal_array_init)
13018 Diag(SL->getBeginLoc(),
13019 diag::note_concatenated_string_literal_silence);
13046 if (!type->isDependentType() && Init && !Init->isValueDependent() &&
13061 HasConstInit = checkConstInit();
13065 if (HasConstInit) {
13068 }
else if (CacheCulprit) {
13069 Notes.emplace_back(CacheCulprit->
getExprLoc(),
13070 PDiag(diag::note_invalid_subexpr_in_const_expr));
13078 if (HasConstInit) {
13084 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
13085 diag::note_invalid_subexpr_in_const_expr) {
13086 DiagLoc = Notes[0].first;
13089 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
13090 << var << Init->getSourceRange();
13091 for (
unsigned I = 0,
N = Notes.size(); I !=
N; ++I)
13092 Diag(Notes[I].first, Notes[I].second);
13096 << Init->getSourceRange();
13099 for (
auto &it : Notes)
13100 Diag(it.first, it.second);
13101 }
else if (IsGlobal &&
13112 if (!checkConstInit())
13114 << Init->getSourceRange();
13120 if (!type->isDependentType())
13130 if (
auto *DD = dyn_cast<DecompositionDecl>(var))
13139 if (I->isAlignmentDependent())
13164 NewAttr->setInherited(
true);
13168 NewAttr->setInherited(
true);
13178 NewAttr->setInherited(
true);
13189 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
13218 if (
auto *DD = dyn_cast<DecompositionDecl>(ThisDecl)) {
13219 for (
auto *BD : DD->bindings()) {
13258 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
13265 bool IsClassTemplateMember =
13267 Context->getDescribedClassTemplate();
13270 IsClassTemplateMember
13271 ? diag::warn_attribute_dllimport_static_field_definition
13272 : diag::err_attribute_dllimport_static_field_definition);
13273 Diag(IA->getLocation(), diag::note_attribute);
13274 if (!IsClassTemplateMember)
13309 if (VD->
isFileVarDecl() && !isa<VarTemplatePartialSpecializationDecl>(VD))
13320 if (!MagicValueExpr) {
13325 Diag(I->getRange().getBegin(),
13326 diag::err_type_tag_for_datatype_not_ice)
13330 if (MagicValueInt->getActiveBits() > 64) {
13331 Diag(I->getRange().getBegin(),
13332 diag::err_type_tag_for_datatype_too_large)
13336 uint64_t MagicValue = MagicValueInt->getZExtValue();
13339 I->getMatchingCType(),
13340 I->getLayoutCompatible(),
13341 I->getMustBeNull());
13346 auto *VD = dyn_cast<VarDecl>(DD);
13347 return VD && !VD->getType()->hasAutoForTrailingReturnType();
13359 bool DiagnosedMultipleDecomps =
false;
13361 bool DiagnosedNonDeducedAuto =
false;
13363 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
13364 if (
Decl *D = Group[i]) {
13367 if (
auto *DD = dyn_cast<DeclaratorDecl>(D)) {
13368 if (!FirstDeclaratorInGroup)
13369 FirstDeclaratorInGroup = DD;
13370 if (!FirstDecompDeclaratorInGroup)
13371 FirstDecompDeclaratorInGroup = dyn_cast<DecompositionDecl>(D);
13374 FirstNonDeducedAutoInGroup = DD;
13376 if (FirstDeclaratorInGroup != DD) {
13379 if (FirstDecompDeclaratorInGroup && !DiagnosedMultipleDecomps) {
13381 diag::err_decomp_decl_not_alone)
13383 << DD->getSourceRange();
13384 DiagnosedMultipleDecomps =
true;
13390 if (FirstNonDeducedAutoInGroup && !DiagnosedNonDeducedAuto) {
13392 diag::err_auto_non_deduced_not_alone)
13393 << FirstNonDeducedAutoInGroup->
getType()
13396 << DD->getSourceRange();
13397 DiagnosedNonDeducedAuto =
true;
13402 Decls.push_back(D);
13409 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
13425 if (Group.size() > 1) {
13427 VarDecl *DeducedDecl =
nullptr;
13428 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
13429 VarDecl *D = dyn_cast<VarDecl>(Group[i]);
13439 auto *AT = dyn_cast<AutoType>(DT);
13441 diag::err_auto_different_deductions)
13442 << (AT ? (
unsigned)AT->getKeyword() : 3) << Deduced
13467 if (Group.empty() || !Group[0])
13471 Group[0]->getLocation()) &&
13473 Group[0]->getLocation()))
13476 if (Group.size() >= 2) {
13484 Decl *MaybeTagDecl = Group[0];
13485 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
13486 Group = Group.slice(1);
13551 : diag::warn_deprecated_register)
13559 diag::err_invalid_storage_class_in_func_decl);
13571 << 0 <<
static_cast<int>(D.
getDeclSpec().getConstexprSpecifier());
13592 PrevDecl =
nullptr;
13593 }
else if (S->isDeclScope(PrevDecl)) {
13615 assert(S->isFunctionPrototypeScope());
13616 assert(S->getFunctionPrototypeDepth() >= 1);
13618 S->getNextFunctionPrototypeIndex());
13653 Param->setImplicit();
13666 Diag(
Parameter->getLocation(), diag::warn_unused_parameter)
13674 if (
LangOpts.NumLargeByValueCopy == 0)
13681 if (Size >
LangOpts.NumLargeByValueCopy)
13689 if (T->isDependentType() || !T.isPODType(
Context))
13692 if (Size >
LangOpts.NumLargeByValueCopy)
13705 T->isObjCLifetimeType()) {
13712 if (T->isArrayType()) {
13713 if (!T.isConstQualified()) {
13717 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
13719 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
13724 lifetime = T->getObjCARCImplicitLifetime();
13731 TSInfo, SC,
nullptr);
13738 LSI->LocalPacks.push_back(New);
13755 if (T->isObjCObjectType()) {
13759 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
13774 Diag(NameLoc, diag::err_arg_with_address_space);
13794 for (
int i = FTI.
NumParams; i != 0; ) {
13798 llvm::raw_svector_ostream(Code)
13808 const char* PrevSpec;
13841 ParentScope, D, TemplateParameterLists, Bases);
13847 if (!Bases.empty())
13869 if (isa<CXXMethodDecl>(FD))
13875 if (II->isStr(
"main"))
13902 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
13905 PossiblePrototype = Prev;
13947 Definition->getDescribedFunctionTemplate() ||
13948 Definition->getNumTemplateParameterLists())) {
13951 if (
auto *TD =
Definition->getDescribedFunctionTemplate())
13964 Diag(
Definition->getLocation(), diag::note_previous_definition);
13974 LSI->
Lambda = LambdaClass;
13992 for (
const auto &
C : LambdaClass->
captures()) {
13993 if (
C.capturesVariable()) {
13997 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
13999 true,
C.getLocation(),
14000 C.isPackExpansion()
14002 I->getType(),
false);
14004 }
else if (
C.capturesThis()) {
14028 FD = FunTmpl->getTemplatedDecl();
14051 if (
auto *Ctor = dyn_cast<CXXConstructorDecl>(FD)) {
14053 Ctor->isDefaultConstructor() &&
14088 "There should be an active template instantiation on the stack "
14089 "when instantiating a generic lambda!");
14111 diag::err_func_def_incomplete_result))
14125 auto *NonParmDecl = dyn_cast<NamedDecl>(NPD);
14128 assert(!isa<ParmVarDecl>(NonParmDecl) &&
14129 "parameters should not be in newly created FD yet");
14132 if (NonParmDecl->getDeclName())
14137 if (
auto *ED = dyn_cast<EnumDecl>(NonParmDecl)) {
14138 for (
auto *EI : ED->enumerators())
14146 Param->setOwningFunction(FD);
14149 if (Param->getIdentifier() && FnBodyScope) {
14164 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
14194 for (
unsigned I = 0, E =
Scope->Returns.size(); I != E; ++I) {
14195 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
14196 if (!NRVOCandidate->isNRVOVariable())
14215 Outer.Fun.hasTrailingReturnType()) {
14233 if (FD->isConstexpr())
14238 if (FD->getReturnType()->getContainedDeducedType())
14248 FD->setHasSkippedBody();
14270 bool IsLambda =
false;
14274 llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
14276 auto IsOrNestedInEscapingBlock = [&](
const BlockDecl *BD) {
14277 if (EscapeInfo.count(BD))
14278 return EscapeInfo[BD];
14290 return EscapeInfo[BD] = R;
14295 for (
const std::pair<SourceLocation, const BlockDecl *> &
P :
14297 if (IsOrNestedInEscapingBlock(
P.second))
14298 S.
Diag(
P.first, diag::warn_implicitly_retains_self)
14303 bool IsInstantiation) {
14346 if (LSI->HasImplicitReturnType) {
14353 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
14358 Proto->getExtProtoInfo()));
14402 if (PossiblePrototype) {
14406 TypeLoc TL = TI->getTypeLoc();
14409 diag::note_declaration_not_a_prototype)
14419 std::pair<FileID, unsigned> LocInfo =
SM.getDecomposedLoc(Loc);
14420 if (LocInfo.first.isInvalid())
14423 bool Invalid =
false;
14424 StringRef Buffer =
SM.getBufferData(LocInfo.first, &Invalid);
14428 if (LocInfo.second > Buffer.size())
14431 const char *LexStart = Buffer.data() + LocInfo.second;
14432 StringRef StartTok(LexStart, Buffer.size() - LocInfo.second);
14434 return StartTok.consume_front(
"const") &&
14436 StartTok.startswith(
"/*") || StartTok.startswith(
"//"));
14439 auto findBeginLoc = [&]() {
14475 if (
const auto *CmpndBody = dyn_cast<CompoundStmt>(Body))
14476 if (!CmpndBody->body_empty())
14477 Diag(CmpndBody->body_front()->getBeginLoc(),
14478 diag::warn_dispatch_body_ignored);
14480 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
14505 "Function parsing confused");
14506 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
14518 << MD->getSelector().getAsString();
14523 bool isDesignated =
14524 MD->isDesignatedInitializerForTheInterface(&InitMethod);
14525 assert(isDesignated && InitMethod);
14526 (void)isDesignated;
14529 auto IFace = MD->getClassInterface();
14532 auto SuperD = IFace->getSuperClass();
14542 diag::warn_objc_designated_init_missing_super_call);
14544 diag::note_objc_designated_init_marked_here);
14552 diag::warn_objc_secondary_init_missing_init_call);
14568 "This should only be set for ObjC methods, which should have been "
14569 "handled in the block above.");
14576 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
14585 if (!Destructor->getParent()->isDependentType())
14589 Destructor->getParent());
14600 !isa<FunctionTemplateDecl>(dcl)) {
14603 ActivePolicy = &WP;
14614 bool RegisterVariables =
false;
14615 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
14616 for (
const auto *
Decl : DS->decls()) {
14617 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
14618 RegisterVariables =
14620 if (!RegisterVariables)
14625 if (RegisterVariables)
14627 if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
14628 Diag(S->getBeginLoc(), diag::err_non_asm_stmt_in_naked_function);
14638 "Leftover temporaries in function");
14639 assert(!Cleanup.exprNeedsCleanups() &&
"Unaccounted cleanups in function");
14641 "Leftover expressions for odr-use checking");
14644 if (!IsInstantiation)
14659 DeclsToCheckForDeferredDiags.push_back(FD);
14671 D = TD->getTemplatedDecl();
14674 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
14675 if (Method->isStatic())
14688 Scope *BlockScope = S;
14692 Scope *ContextScope = BlockScope;
14694 ContextScope = ContextScope->
getParent();
14710 if (!isa<FunctionDecl>(ExternCPrev) ||
14712 cast<FunctionDecl>(ExternCPrev)->getType(),
14714 Diag(Loc, diag::ext_use_out_of_scope_declaration)
14717 return ExternCPrev;
14723 if (II.
getName().startswith(
"__builtin_"))
14724 diag_id = diag::warn_builtin_unknown;
14727 diag_id = diag::err_opencl_implicit_function_decl;
14729 diag_id = diag::ext_implicit_function_decl;
14731 diag_id = diag::warn_implicit_function_decl;
14732 Diag(Loc, diag_id) << &II;
14738 return ExternCPrev;
14745 if (S && (Corrected =
14760 assert(!Error &&
"Error setting up implicit decl!");
14809 bool IsNothrow =
false;
14881 unsigned FormatIdx;
14885 const char *fmt =
"printf";
14887 if (FormatIdx < NumParams &&
14893 HasVAListArg ? 0 : FormatIdx+2,
14903 HasVAListArg ? 0 : FormatIdx+2,
14925 if ((Trip.isGNUEnvironment() || Trip.isAndroid() || Trip.isOSMSVCRT()) &&
14927 switch (BuiltinID) {
14928 case Builtin::BI__builtin_fma:
14929 case Builtin::BI__builtin_fmaf:
14930 case Builtin::BI__builtin_fmal:
14931 case Builtin::BIfma:
14932 case Builtin::BIfmaf:
14933 case Builtin::BIfmal:
14972 if (!FPT || FPT->getExceptionSpecType() ==
EST_None)
14989 if (Name->isStr(
"asprintf") || Name->isStr(
"vasprintf")) {
14995 Name->isStr(
"vasprintf") ? 0 : 3,
14999 if (Name->isStr(
"__CFStringMakeConstantString")) {
15010 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
15011 assert(!T.isNull() &&
"GetTypeForDeclarator() returned null type");
15014 assert(D.
isInvalidType() &&
"no declarator info for valid type");
15069 if (T->isDependentType())
15075 if (BT->isInteger())
15078 if (T->isExtIntType())
15081 return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
15087 QualType EnumUnderlyingTy,
bool IsFixed,
15089 if (IsScoped != Prev->
isScoped()) {
15090 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
15096 if (IsFixed && Prev->
isFixed()) {
15102 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
15108 }
else if (IsFixed != Prev->
isFixed()) {
15109 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
15128 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
15143 if (isa<TypedefDecl>(PrevDecl))
15145 else if (isa<TypeAliasDecl>(PrevDecl))
15147 else if (isa<ClassTemplateDecl>(PrevDecl))
15149 else if (isa<TypeAliasTemplateDecl>(PrevDecl))
15151 else if (isa<TemplateTemplateParmDecl>(PrevDecl))
15163 llvm_unreachable(
"invalid TTK");
15188 if (OldTag != NewTag &&
15206 if (IsIgnoredLoc(NewTagLoc))
15209 auto IsIgnored = [&](
const TagDecl *Tag) {
15210 return IsIgnoredLoc(Tag->getLocation());
15221 isTemplate = Record->getDescribedClassTemplate();
15224 if (OldTag != NewTag) {
15227 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
15235 if (isDefinition) {
15243 bool previousMismatch =
false;
15245 if (I->getTagKind() != NewTag) {
15250 if (!previousMismatch) {
15251 previousMismatch =
true;
15252 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
15256 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
15269 if (PrevDef && IsIgnored(PrevDef))
15273 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
15280 Diag(NewTagLoc, diag::note_struct_class_suggestion)
15310 if (!Namespace || Namespace->isAnonymousNamespace())
15313 Namespaces.push_back(II);
15316 if (Lookup == Namespace)
15323 llvm::raw_svector_ostream OS(Insertion);
15326 std::reverse(Namespaces.begin(), Namespaces.end());
15327 for (
auto *II : Namespaces)
15328 OS << II->getName() <<
"::";
15341 if (OldDC->
Equals(NewDC))
15369 bool &OwnedDecl,
bool &IsDependent,
15371 bool ScopedEnumUsesClassTag,
TypeResult UnderlyingType,
15372 bool IsTypeSpecifier,
bool IsTemplateParamOrArg,
15377 "Nameless record must be a definition!");
15378 assert(TemplateParameterLists.size() == 0 || TUK !=
TUK_Reference);
15382 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
15385 bool isMemberSpecialization =
false;
15386 bool Invalid =
false;
15391 if (TemplateParameterLists.size() > 0 ||
15395 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
15396 TUK ==
TUK_Friend, isMemberSpecialization, Invalid)) {
15398 Diag(KWLoc, diag::err_enum_template);
15402 if (TemplateParams->size() > 0) {
15411 S, TagSpec, TUK, KWLoc, SS, Name, NameLoc, Attrs, TemplateParams,
15412 AS, ModulePrivateLoc,
15414 TemplateParameterLists.data(), SkipBody);
15418 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
15420 isMemberSpecialization =
true;
15424 if (!TemplateParameterLists.empty() && isMemberSpecialization &&
15432 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
15433 bool IsFixed = !UnderlyingType.
isUnset() || ScopedEnum;
15436 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum)) {
15440 }
else if (UnderlyingType.
get()) {
15445 EnumUnderlying = TI;
15467 bool isStdBadAlloc =
false;
15468 bool isStdAlignValT =
false;
15477 auto createTagFromNewDecl = [&]() ->
TagDecl * {
15487 ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
15491 if (EnumUnderlying) {
15504 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
15530 goto CreateNewDecl;
15538 IsDependent =
true;
15567 if (
Previous.wasNotFoundInCurrentInstantiation() &&
15569 IsDependent =
true;
15574 Diag(NameLoc, diag::err_not_tag_in_scope)
15575 << Kind << Name << DC << SS.
getRange();
15578 goto CreateNewDecl;
15626 bool FriendSawTagOutsideEnclosingNamespace =
false;
15633 FriendSawTagOutsideEnclosingNamespace =
true;
15642 if (
Previous.isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
15644 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
15658 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
15664 Previous.getFoundDecl()->isTemplateParameter()) {
15673 if (Name->isStr(
"bad_alloc")) {
15675 isStdBadAlloc =
true;
15682 }
else if (Name->isStr(
"align_val_t")) {
15683 isStdAlignValT =
true;
15695 if (Invalid)
goto CreateNewDecl;
15777 TagDecl *Tag = TT->getDecl();
15778 if (Tag->getDeclName() == Name &&
15779 Tag->getDeclContext()->getRedeclContext()
15780 ->Equals(TD->getDeclContext()->getRedeclContext())) {
15793 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
15794 auto *OldTag = dyn_cast<TagDecl>(PrevDecl);
15796 isDeclInScope(Shadow, SearchDC, S, isMemberSpecialization) &&
15798 *
this, OldTag->getDeclContext(), SearchDC))) {
15799 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
15800 Diag(Shadow->getTargetDecl()->getLocation(),
15801 diag::note_using_decl_target);
15802 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
15806 goto CreateNewDecl;
15810 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
15816 SS.
isNotEmpty() || isMemberSpecialization)) {
15822 bool SafeToContinue
15823 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
15825 if (SafeToContinue)
15826 Diag(KWLoc, diag::err_use_with_wrong_tag)
15829 PrevTagDecl->getKindName());
15831 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
15832 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
15834 if (SafeToContinue)
15835 Kind = PrevTagDecl->getTagKind();
15847 return PrevTagDecl;
15851 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
15852 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
15853 EnumUnderlyingTy =
QualType(T, 0);
15859 ScopedEnum, EnumUnderlyingTy,
15860 IsFixed, PrevEnum))
15869 S->isDeclScope(PrevDecl)) {
15870 Diag(NameLoc, diag::ext_member_redeclared);
15871 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
15878 if (!Attrs.
empty()) {
15882 (PrevTagDecl->getFriendObjectKind() ==
15895 return PrevTagDecl;
15900 return PrevTagDecl;
15906 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
15910 bool IsExplicitSpecializationAfterInstantiation =
false;
15911 if (isMemberSpecialization) {
15913 IsExplicitSpecializationAfterInstantiation =
15914 RD->getTemplateSpecializationKind() !=
15916 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
15917 IsExplicitSpecializationAfterInstantiation =
15918 ED->getTemplateSpecializationKind() !=
15938 SkipBody->
New = createTagFromNewDecl();
15948 }
else if (!IsExplicitSpecializationAfterInstantiation) {
15952 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
15954 Diag(NameLoc, diag::err_redefinition) << Name;
15956 NameLoc.
isValid() ? NameLoc : KWLoc);
15968 if (TD->isBeingDefined()) {
15969 Diag(NameLoc, diag::err_nested_redefinition) << Name;
15970 Diag(PrevTagDecl->getLocation(),
15971 diag::note_previous_definition);
15986 SearchDC = PrevTagDecl->getDeclContext();
16014 Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
16021 SS.
isNotEmpty() || isMemberSpecialization)) {
16027 Diag(NameLoc, diag::err_tag_reference_conflict) << NTK;
16033 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
16035 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
16036 Diag(NameLoc, diag::err_tag_definition_of_typedef)
16037 << Name << Kind << TND->getUnderlyingType();
16045 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
16077 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
16078 ScopedEnumUsesClassTag, IsFixed);
16086 if (IsFixed && cast<EnumDecl>(New)->isFixed()) {
16090 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
16091 Diag(Loc, diag::ext_forward_ref_enum_def)
16095 unsigned DiagID = diag::ext_forward_ref_enum;
16097 DiagID = diag::ext_ms_forward_ref_enum;
16099 DiagID = diag::err_forward_ref_enum;
16104 if (EnumUnderlying) {
16111 assert(ED->
isComplete() &&
"enum with type should be complete");
16121 cast_or_null<CXXRecordDecl>(PrevDecl));
16127 cast_or_null<RecordDecl>(PrevDecl));
16153 isMemberSpecialization))
16157 if (TemplateParameterLists.size() > 0) {
16165 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
16181 if (ModulePrivateLoc.
isValid()) {
16182 if (isMemberSpecialization)
16207 Diag(Loc, diag::err_type_defined_in_param_type)
16211 }
else if (!PrevDecl) {
16231 if (!Invalid && SearchDC->
isRecord())
16272 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(New))
16287 if (
auto RD = dyn_cast<RecordDecl>(New))
16290 }
else if (SkipBody && SkipBody->
ShouldSkip) {
16322 assert(isa<ObjCContainerDecl>(IDecl) &&
16323 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
16326 "The next DeclContext should be lexically contained in the current one.");
16333 bool IsFinalSpelledSealed,
16340 if (!Record->getIdentifier())
16355 Record->getLocation(), Record->getIdentifier(),
16365 "Broken injected-class-name");
16372 Tag->setBraceRange(BraceRange);
16375 if (Tag->isBeingDefined()) {
16376 assert(Tag->isInvalidDecl() &&
"We should already have completed it");
16377 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
16381 if (isa<CXXRecordDecl>(Tag)) {
16390 Tag->setTopLevelDeclInObjCContainer();
16393 if (!Tag->isInvalidDecl())
16403 assert(DC ==
CurContext &&
"Mismatch of container contexts");
16416 Tag->setInvalidDecl();
16419 if (Tag->isBeingDefined()) {
16420 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
16434 QualType FieldTy,
bool IsMsStruct,
16435 Expr *BitWidth,
bool *ZeroWidth) {
16449 diag::err_field_incomplete_or_sizeless))
16452 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
16454 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
16465 llvm::APSInt
Value;
16469 BitWidth = ICE.
get();
16471 if (
Value != 0 && ZeroWidth)
16472 *ZeroWidth =
false;
16475 if (
Value == 0 && FieldName)
16476 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
16478 if (
Value.isSigned() &&
Value.isNegative()) {
16480 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
16481 << FieldName <<
Value.toString(10);
16482 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
16483 <<
Value.toString(10);
16489 return Diag(FieldLoc, diag::err_bitfield_too_wide)
16490 << !FieldName << FieldName <<
Value.toString(10);
16496 bool BitfieldIsOverwide =
Value.ugt(TypeWidth);
16500 bool CStdConstraintViolation =
16502 bool MSBitfieldViolation =
16503 Value.ugt(TypeStorageSize) &&
16505 if (CStdConstraintViolation || MSBitfieldViolation) {
16506 unsigned DiagWidth =
16507 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
16509 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
16510 << FieldName <<
Value.toString(10)
16511 << !CStdConstraintViolation << DiagWidth;
16513 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
16514 <<
Value.toString(10) << !CStdConstraintViolation
16521 if (BitfieldIsOverwide && !FieldTy->
isBooleanType() && FieldName) {
16522 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
16523 << FieldName <<
Value.toString(10)
16536 DeclStart, D,
static_cast<Expr*
>(BitfieldWidth),
16579 diag::err_invalid_thread)
16587 switch (
Previous.getResultKind()) {
16594 PrevDecl =
Previous.getRepresentativeDecl();
16608 PrevDecl =
nullptr;
16612 PrevDecl =
nullptr;
16618 =
CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
16619 TSSL, AS, PrevDecl, &D);
16622 Record->setInvalidDecl();
16633 Record->addDecl(NewFD);
16651 bool Mutable,
Expr *BitWidth,
16657 bool InvalidDecl =
false;
16662 if (T.isNull() || T->containsErrors()) {
16663 InvalidDecl =
true;
16670 diag::err_field_incomplete_or_sizeless)) {
16672 Record->setInvalidDecl();
16673 InvalidDecl =
true;
16678 Record->setInvalidDecl();
16679 InvalidDecl =
true;
16685 if (T.hasAddressSpace() || T->isDependentAddressSpaceType() ||
16686 T->getBaseElementTypeUnsafe()->isDependentAddressSpaceType()) {
16687 Diag(Loc, diag::err_field_with_address_space);
16688 Record->setInvalidDecl();
16689 InvalidDecl =
true;
16695 if (T->isEventT() || T->isImageType() || T->isSamplerT() ||
16696 T->isBlockPointerType()) {
16697 Diag(Loc, diag::err_opencl_type_struct_or_union_field) << T;
16698 Record->setInvalidDecl();
16699 InvalidDecl =
true;
16703 Diag(Loc, diag::err_opencl_bitfields);
16704 InvalidDecl =
true;
16710 T.hasQualifiers()) {
16711 InvalidDecl =
true;
16712 Diag(Loc, diag::err_anon_bitfield_qualifiers);
16717 if (!InvalidDecl && T->isVariablyModifiedType()) {
16719 *
this, TInfo, T, Loc, diag::err_typecheck_field_variable_size))
16720 InvalidDecl =
true;
16725 diag::err_abstract_type_in_decl,
16727 InvalidDecl =
true;
16729 bool ZeroWidth =
false;
16731 BitWidth =
nullptr;
16737 InvalidDecl =
true;
16738 BitWidth =
nullptr;
16744 if (!InvalidDecl && Mutable) {
16745 unsigned DiagID = 0;
16746 if (T->isReferenceType())
16747 DiagID =
getLangOpts().MSVCCompat ? diag::ext_mutable_reference
16748 : diag::err_mutable_reference;
16749 else if (T.isConstQualified())
16750 DiagID = diag::err_mutable_const;
16756 Diag(ErrLoc, DiagID);
16757 if (DiagID != diag::ext_mutable_reference) {
16759 InvalidDecl =
true;
16771 BitWidth, Mutable, InitStyle);
16775 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
16776 Diag(Loc, diag::err_duplicate_member) << II;
16782 if (Record->isUnion()) {
16801 diag::ext_union_member_of_reference_type :
16802 diag::err_union_member_of_reference_type)
16825 if (T.isObjCGCWeak())
16826 Diag(Loc, diag::warn_attribute_weak_on_field);
16885 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
16886 diag::err_illegal_union_or_anon_struct_member)
16901 switch (ivarVisibility) {
16902 default: llvm_unreachable(
"Unknown visitibility kind");
16918 Expr *BitWidth = (
Expr*)BitfieldWidth;
16939 if (T->isReferenceType()) {
16940 Diag(Loc, diag::err_ivar_reference_type);
16945 else if (T->isVariablyModifiedType()) {
16947 *
this, TInfo, T, Loc, diag::err_typecheck_ivar_variable_size))
16961 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
16964 EnclosingContext = IMPDecl->getClassInterface();
16965 assert(EnclosingContext &&
"Implementation has no class interface!");
16968 EnclosingContext = EnclosingDecl;
16971 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
16973 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
16977 EnclosingContext = EnclosingDecl;
16982 DeclStart, Loc, II, T,
16983 TInfo, ac, (
Expr *)BitfieldWidth);
16988 if (PrevDecl &&
isDeclInScope(PrevDecl, EnclosingContext, S)
16989 && !isa<TagDecl>(PrevDecl)) {
16990 Diag(Loc, diag::err_duplicate_member) << II;
17017 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
17018 Diag(Loc, diag::warn_ivars_in_interface);
17032 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
17040 if (!CD->IsClassExtension())
17052 DeclLoc, DeclLoc,
nullptr,
17058 AllIvarDecls.push_back(Ivar);
17065 assert(EnclosingDecl &&
"missing record or interface decl");
17070 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
17074 case Decl::ObjCCategory:
17077 case Decl::ObjCImplementation:
17079 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
17084 RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl);
17085 CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(EnclosingDecl);
17089 unsigned NumNamedMembers = 0;
17091 for (
const auto *I : Record->decls()) {
17092 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
17093 if (IFD->getDeclName())
17110 RecFields.push_back(FD);
17130 bool IsLastField = (i + 1 == Fields.end());
17139 (Record || isa<ObjCContainerDecl>(EnclosingDecl))) {
17145 unsigned DiagID = 0;
17146 if (!Record->isUnion() && !IsLastField) {
17149 Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
17153 }
else if (Record->isUnion())
17155 ? diag::ext_flexible_array_union_ms
17157 ? diag::ext_flexible_array_union_gnu
17158 : diag::err_flexible_array_union;
17159 else if (NumNamedMembers < 1)
17161 ? diag::ext_flexible_array_empty_aggregate_ms
17163 ? diag::ext_flexible_array_empty_aggregate_gnu
17164 : diag::err_flexible_array_empty_aggregate;
17168 << Record->getTagKind();
17174 if (CXXRecord && CXXRecord->getNumVBases() != 0)
17188 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
17195 Record->setHasFlexibleArrayMember(
true);
17204 diag::err_field_incomplete_or_sizeless)) {
17210 if (Record && FDTTy->getDecl()->hasFlexibleArrayMember()) {
17213 Record->setHasFlexibleArrayMember(
true);
17214 if (!Record->isUnion()) {
17229 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
17231 diag::err_abstract_type_in_decl,
17236 if (Record && FDTTy->getDecl()->hasObjectMember())
17237 Record->setHasObjectMember(
true);
17238 if (Record && FDTTy->getDecl()->hasVolatileMember())
17239 Record->setHasVolatileMember(
true);
17246 }
else if (Record && Record->isUnion() &&
17263 !Record->hasObjectMember()) {
17266 Record->setHasObjectMember(
true);
17269 if (BaseType->isRecordType() &&
17271 Record->setHasObjectMember(
true);
17272 else if (BaseType->isObjCObjectPointerType() ||
17273 BaseType.isObjCGCStrong())
17274 Record->setHasObjectMember(
true);
17279 !shouldIgnoreForRecordTriviality(FD)) {
17282 Record->setNonTrivialToPrimitiveDefaultInitialize(
true);
17285 Record->setHasNonTrivialToPrimitiveDefaultInitializeCUnion(
true);
17289 Record->setNonTrivialToPrimitiveCopy(
true);
17291 Record->setHasNonTrivialToPrimitiveCopyCUnion(
true);
17294 Record->setNonTrivialToPrimitiveDestroy(
true);
17295 Record->setParamDestroyedInCallee(
true);
17297 Record->setHasNonTrivialToPrimitiveDestructCUnion(
true);
17301 if (RT->getDecl()->getArgPassingRestrictions() ==
17309 Record->setHasVolatileMember(
true);
17317 bool Completed =
false;
17319 if (!CXXRecord->isInvalidDecl()) {
17322 I = CXXRecord->conversion_begin(),
17323 E = CXXRecord->conversion_end(); I != E; ++I)
17324 I.setAccess((*I)->getAccess());
17330 if (!CXXRecord->isDependentType()) {
17331 if (!CXXRecord->isInvalidDecl()) {
17335 if (CXXRecord->getNumVBases()) {
17337 CXXRecord->getFinalOverriders(FinalOverriders);
17339 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
17340 MEnd = FinalOverriders.end();
17343 SOEnd = M->second.end();
17344 SO != SOEnd; ++SO) {
17345 assert(SO->second.size() > 0 &&
17346 "Virtual function without overriding functions?");
17347 if (SO->second.size() == 1)
17354 Diag(Record->getLocation(), diag::err_multiple_final_overriders)
17355 << (
const NamedDecl *)M->first << Record;
17356 Diag(M->first->getLocation(),
17357 diag::note_overridden_virtual_function);
17359 OM = SO->second.begin(),
17360 OMEnd = SO->second.end();
17362 Diag(OM->Method->getLocation(), diag::note_final_overrider)
17363 << (
const NamedDecl *)M->first << OM->Method->getParent();
17365 Record->setInvalidDecl();
17368 CXXRecord->completeDefinition(&FinalOverriders);
17376 Record->completeDefinition();
17383 auto *Dtor = CXXRecord->getDestructor();
17384 if (Dtor && Dtor->isImplicit() &&
17386 CXXRecord->setImplicitDestructorIsDeleted();
17391 if (Record->hasAttrs()) {
17396 IA->getRange(), IA->getBestCase(),
17397 IA->getInheritanceModel());
17403 bool CheckForZeroSize;
17405 CheckForZeroSize =
true;
17410 CXXRecord->getLexicalDeclContext()->isExternCContext() &&
17412 CXXRecord->isCLike();
17414 if (CheckForZeroSize) {
17415 bool ZeroSize =
true;
17416 bool IsEmpty =
true;
17417 unsigned NonBitFields = 0;
17419 E = Record->field_end();
17420 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
17422 if (I->isUnnamedBitfield()) {
17423 if (!I->isZeroLengthBitField(
Context))
17427 QualType FieldType = I->getType();
17439 diag::warn_zero_size_struct_union_in_extern_c :
17440 diag::warn_zero_size_struct_union_compat)
17441 << IsEmpty << Record->isUnion() << (NonBitFields > 1);
17447 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
17448 diag::ext_no_named_members_in_struct_union)
17449 << Record->isUnion();
17456 ID->setEndOfDefinitionLoc(RBrac);
17458 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
17460 ID->addDecl(ClsFields[i]);
17464 if (ID->getSuperClass())
17467 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
17468 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
17469 for (
unsigned I = 0,
N = RecFields.size(); I !=
N; ++I)
17474 IMPDecl->setIvarLBraceLoc(LBrac);
17475 IMPDecl->setIvarRBraceLoc(RBrac);
17477 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
17485 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
17489 Diag(ClsFields[i]->getLocation(),
17490 diag::err_duplicate_ivar_declaration);
17491 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
17497 Diag(ClsFields[i]->getLocation(),
17498 diag::err_duplicate_ivar_declaration);
17499 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
17505 CDecl->addDecl(ClsFields[i]);
17507 CDecl->setIvarLBraceLoc(LBrac);
17508 CDecl->setIvarRBraceLoc(RBrac);
17516 llvm::APSInt &
Value,
17518 assert((T->isIntegralType(Context) || T->isEnumeralType()) &&
17519 "Integral type required!");
17522 if (
Value.isUnsigned() ||
Value.isNonNegative()) {
17523 if (T->isSignedIntegerOrEnumerationType())
17525 return Value.getActiveBits() <= BitWidth;
17527 return Value.getMinSignedBits() <= BitWidth;
17535 assert((T->isIntegralType(Context) ||
17536 T->isEnumeralType()) &&
"Integral type required!");
17537 const unsigned NumTypes = 4;
17538 QualType SignedIntegralTypes[NumTypes] = {
17541 QualType UnsignedIntegralTypes[NumTypes] = {
17547 QualType *Types = T->isSignedIntegerOrEnumerationType()? SignedIntegralTypes
17548 : UnsignedIntegralTypes;
17549 for (
unsigned I = 0; I != NumTypes; ++I)
17562 llvm::APSInt EnumVal(IntWidth);
17581 EltTy =
Enum->getIntegerType();
17588 Val = Converted.
get();
17595 if (
Enum->isComplete()) {
17596 EltTy =
Enum->getIntegerType();
17605 .isWindowsMSVCEnvironment()) {
17606 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
17608 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
17632 Diag(IdLoc, diag::ext_enum_value_not_int)
17634 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
17646 if (
Enum->isDependentType())
17648 else if (!LastEnumConst) {
17657 if (
Enum->isFixed()) {
17658 EltTy =
Enum->getIntegerType();
17667 EltTy = LastEnumConst->
getType();
17670 if (EnumVal < LastEnumConst->getInitVal()) {
17682 if (T.isNull() ||
Enum->isFixed()) {
17686 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
17688 if (
Enum->isFixed())
17690 Diag(IdLoc, diag::err_enumerator_wrapped)
17691 << EnumVal.toString(10)
17694 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
17695 << EnumVal.toString(10);
17714 Diag(IdLoc, diag::warn_enum_value_overflow);
17718 Diag(IdLoc, diag::ext_enum_value_not_int)
17719 << EnumVal.toString(10) << 1;
17746 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
17767 cast_or_null<EnumConstantDecl>(lastEnumConst);
17783 PrevDecl =
nullptr;
17801 if (!TheEnumDecl->
isScoped() && isa<ValueDecl>(PrevDecl)) {
17809 "Received TagDecl when not in C++!");
17811 if (isa<EnumConstantDecl>(PrevDecl))
17812 Diag(IdLoc, diag::err_redefinition_of_enumerator) <<
Id;
17814 Diag(IdLoc, diag::err_redefinition) <<
Id;
17846 if (!BO->isAdditiveOp())
17854 InitExpr = BO->getLHS();
17858 DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InitExpr);
17878 if (!
Enum->getIdentifier())
17882 if (
Enum->getNumPositiveBits() > 63 ||
Enum->getNumNegativeBits() > 64)
17891 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
17894 typedef std::unordered_map<int64_t, DeclOrVector> ValueToVectorMap;
17898 llvm::APSInt Val = D->getInitVal();
17899 return Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue();
17902 DuplicatesVector DupVector;
17903 ValueToVectorMap EnumMap;
17907 for (
auto *Element : Elements) {
17921 EnumMap.insert({EnumConstantToKey(ECD), ECD});
17924 if (EnumMap.size() == 0)
17928 for (
auto *Element : Elements) {
17934 auto Iter = EnumMap.find(EnumConstantToKey(ECD));
17935 if (Iter == EnumMap.end())
17938 DeclOrVector& Entry = Iter->second;
17945 auto Vec = std::make_unique<ECDVector>();
17947 Vec->push_back(ECD);
17954 DupVector.emplace_back(std::move(Vec));
17958 ECDVector *Vec = Entry.get<ECDVector*>();
17960 if (*Vec->begin() == ECD)
17963 Vec->push_back(ECD);
17967 for (
const auto &Vec : DupVector) {
17968 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
17971 auto *FirstECD = Vec->front();
17972 S.
Diag(FirstECD->getLocation(), diag::warn_duplicate_enum_values)
17973 << FirstECD << FirstECD->getInitVal().toString(10)
17974 << FirstECD->getSourceRange();
17978 for (
auto *ECD : llvm::make_range(Vec->begin() + 1, Vec->end()))
17979 S.
Diag(ECD->getLocation(), diag::note_duplicate_element)
17980 << ECD << ECD->getInitVal().toString(10)
17981 << ECD->getSourceRange();
17986 bool AllowMask)
const {
17987 assert(ED->
isClosedFlag() &&
"looking for value in non-flag or open enum");
17990 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
17991 llvm::APInt &FlagBits = R.first->second;
17995 const auto &EVal = E->getInitVal();
17997 if (EVal.isPowerOf2())
17998 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
18010 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
18011 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
18022 if (
Enum->isDependentType()) {
18023 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
18025 cast_or_null<EnumConstantDecl>(Elements[i]);
18026 if (!ECD)
continue;
18044 unsigned NumNegativeBits = 0;
18045 unsigned NumPositiveBits = 0;
18048 bool AllElementsInt =
true;
18050 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
18052 cast_or_null<EnumConstantDecl>(Elements[i]);
18053 if (!ECD)
continue;
18055 const llvm::APSInt &InitVal = ECD->
getInitVal();
18058 if (InitVal.isUnsigned() || InitVal.isNonNegative())
18059 NumPositiveBits = std::max(NumPositiveBits,
18060 (
unsigned)InitVal.getActiveBits());
18062 NumNegativeBits = std::max(NumNegativeBits,
18063 (
unsigned)InitVal.getMinSignedBits());
18066 if (AllElementsInt)
18072 unsigned BestWidth;
18093 if (
Enum->isComplete()) {
18094 BestType =
Enum->getIntegerType();
18098 BestPromotionType = BestType;
18102 else if (NumNegativeBits) {
18106 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
18108 BestWidth = CharWidth;
18109 }
else if (Packed && NumNegativeBits <= ShortWidth &&
18110 NumPositiveBits < ShortWidth) {
18112 BestWidth = ShortWidth;
18113 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
18115 BestWidth = IntWidth;
18119 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
18124 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
18125 Diag(
Enum->getLocation(), diag::ext_enum_too_large);
18129 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
18134 if (Packed && NumPositiveBits <= CharWidth) {
18137 BestWidth = CharWidth;
18138 }
else if (Packed && NumPositiveBits <= ShortWidth) {
18141 BestWidth = ShortWidth;
18142 }
else if (NumPositiveBits <= IntWidth) {
18144 BestWidth = IntWidth;
18146 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
18148 }
else if (NumPositiveBits <=
18152 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
18156 assert(NumPositiveBits <= BestWidth &&
18157 "How could an initializer get larger than ULL?");
18160 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
18167 for (
auto *D : Elements) {
18168 auto *ECD = cast_or_null<EnumConstantDecl>(D);
18169 if (!ECD)
continue;
18178 llvm::APSInt InitVal = ECD->getInitVal();
18186 !
Enum->isFixed() &&
18189 NewWidth = IntWidth;
18191 }
else if (ECD->getType() == BestType) {
18201 NewWidth = BestWidth;
18206 InitVal = InitVal.extOrTrunc(NewWidth);
18207 InitVal.setIsSigned(NewSign);
18208 ECD->setInitVal(InitVal);
18211 if (ECD->getInitExpr() &&
18214 Context, NewTy, CK_IntegralCast, ECD->getInitExpr(),
18222 ECD->setType(NewTy);
18225 Enum->completeDefinition(BestType, BestPromotionType,
18226 NumPositiveBits, NumNegativeBits);
18230 if (
Enum->isClosedFlag()) {
18231 for (
Decl *D : Elements) {
18233 if (!ECD)
continue;
18236 if (InitVal != 0 && !InitVal.isPowerOf2() &&
18244 if (
Enum->hasAttrs())
18254 AsmString, StartLoc,
18276 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
18280 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
18296 std::pair<IdentifierInfo*,WeakInfo>
18310 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
18312 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
18316 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
18321 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
18336 auto IsEmittedForExternalSymbol = [
this, FD]() {
18355 if (DevTy.hasValue())
18361 if (IsEmittedForExternalSymbol())
18367 }
else if (
LangOpts.OpenMP > 45) {
18373 if (DevTy.hasValue())
18393 if (IsEmittedForExternalSymbol())
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
static const Builtin::Info BuiltinInfo[]
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
static bool isDeclExternC(const T &D)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
Defines the clang::Expr interface and subclasses for C++ expressions.
static const Decl * getCanonicalDecl(const Decl *D)
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
static const GlobalDecl isTemplate(GlobalDecl GD, const TemplateArgumentList *&TemplateArgs)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static bool isExternC(const NamedDecl *ND)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
static bool hasAttr(const FunctionDecl *D, bool IgnoreImplicitAttr)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void diagnoseImplicitlyRetainedSelf(Sema &S)
static void SetNestedNameSpecifier(Sema &S, DeclaratorDecl *DD, Declarator &D)
static UnqualifiedTypeNameLookupResult lookupUnqualifiedTypeNameInBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc, const CXXRecordDecl *RD)
Tries to perform unqualified lookup of the type decls in bases for dependent class.
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossiblePrototype)
static bool PreviousDeclsHaveMultiVersionAttribute(const FunctionDecl *FD)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD, DeclaratorDecl *OldD)
If necessary, adjust the semantic declaration context for a qualified declaration to name the correct...
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
static TypeSourceInfo * TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
static StringRef getHeaderName(Builtin::Context &BuiltinInfo, unsigned ID, ASTContext::GetBuiltinTypeError Error)
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid,...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
static ShadowedDeclKind computeShadowedDeclKind(const NamedDecl *ShadowedDecl, const DeclContext *OldDC)
Determine what kind of declaration we're shadowing.
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one.
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
static bool CheckTargetCausesMultiVersioning(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, const TargetAttr *NewTA, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD)
Given that we are within the definition of the given function, will that definition behave like C99's...
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T.
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
static bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class,...
static bool tryToFixVariablyModifiedVarType(Sema &S, TypeSourceInfo *&TInfo, QualType &T, SourceLocation Loc, unsigned FailedFoldDiagID)
Attempt to fold a variable-sized type to a constant-sized type, returning true if we were successful.
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
static NonCLikeKind getNonCLikeKindForAnonymousStruct(const CXXRecordDecl *RD)
Determine whether a class is C-like, according to the rules of C++ [dcl.typedef] for anonymous classe...
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
static Scope * getTagInjectionScope(Scope *S, const LangOptions &LangOpts)
Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the sp...
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
static bool DeclHasAttr(const Decl *D, const Attr *A)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context, const FunctionDecl *New)
Determine whether we allow overloading of the function PrevDecl with another declaration.
static bool isOpenCLSizeDependentType(ASTContext &C, QualType Ty)
static void diagnoseMissingConstinit(Sema &S, const VarDecl *InitDecl, const ConstInitAttr *CIAttr, bool AttrBeforeInit)
static bool shouldWarnIfShadowedDecl(const DiagnosticsEngine &Diags, const LookupResult &R)
static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static bool checkGlobalOrExternCConflict(Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
Check for conflict between this global or extern "C" declaration and previous global or extern "C" de...
@ InvalidAddrSpacePtrKernelParam
static bool AttrCompatibleWithMultiVersion(attr::Kind Kind, MultiVersionKind MVType)
static const CXXRecordDecl * findRecordWithDependentBasesOfEnclosingMethod(const DeclContext *DC)
Find the parent class with dependent bases of the innermost enclosing method context.
static bool shouldConsiderLinkage(const VarDecl *VD)
static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D, DeclContext *DC, QualType R)
Returns true if there hasn't been any invalid type diagnosed.
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
static bool checkNonMultiVersionCompatAttributes(Sema &S, const FunctionDecl *FD, const FunctionDecl *CausedFD, MultiVersionKind MVType)
static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD, const FunctionDecl *NewFD, bool CausesMV, MultiVersionKind MVType)
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message.
static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl *Old)
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in th...
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
static bool hasParsedAttr(Scope *S, const Declarator &PD, ParsedAttr::Kind Kind)
static bool CheckMultiVersionFirstFunction(Sema &S, FunctionDecl *FD, MultiVersionKind MVType, const TargetAttr *TA)
Check the validity of a multiversion function declaration that is the first of its kind.
ShadowedDeclKind
Enum describing the select options in diag::warn_decl_shadow.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl * > &Chaining)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T)
static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations from the lookup results.
static bool hasDependentAlignment(VarDecl *VD)
Determines if a variable's alignment is dependent.
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a mulitversion function declaration.
static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S)
static const NamedDecl * getDefinition(const Decl *D)
static bool isUsingDecl(NamedDecl *D)
static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Helper method to turn variable array types into constant array types in certain situations which woul...
static bool hasDeducedAuto(DeclaratorDecl *DD)
static QualType getCoreType(QualType Ty)
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
static bool CheckMultiVersionValue(Sema &S, const FunctionDecl *FD)
Check the target attribute of the function for MultiVersion validity.
static void CheckPoppedLabel(LabelDecl *L, Sema &S)
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration.
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
static bool CheckMultiVersionAdditionalDecl(Sema &S, FunctionDecl *OldFD, FunctionDecl *NewFD, MultiVersionKind NewMVType, const TargetAttr *NewTA, const CPUDispatchAttr *NewCPUDisp, const CPUSpecificAttr *NewCPUSpec, bool &Redeclaration, NamedDecl *&OldDecl, bool &MergeTypeWithPrevious, LookupResult &Previous)
Check the validity of a new function declaration being added to an existing multiversioned declaratio...
static ParsedType buildNestedType(Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI, const VarDecl *VD)
Return the location of the capture if the given lambda captures the given variable VD,...
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization, bool IsDefinition)
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
static bool isAttributeTargetADefinition(Decl *D)
static Attr * getImplicitCodeSegAttrFromClass(Sema &S, const FunctionDecl *FD)
Return a CodeSegAttr from a containing class.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualified na...
static bool isRecordType(QualType T)
Defines the SourceManager interface.
const NestedNameSpecifier * Specifier
RAII object that pops an ExpressionEvaluationContext when exiting a function body.
ExitFunctionBodyRAII(Sema &S, bool IsLambda)
llvm::APInt getValue() const
virtual void HandleTagDeclDefinition(TagDecl *D)
HandleTagDeclDefinition - This callback is invoked each time a TagDecl (e.g.
virtual void HandleInlineFunctionDefinition(FunctionDecl *D)
This callback is invoked each time an inline (method or friend) function definition in a class is com...
virtual bool shouldSkipFunctionBody(Decl *D)
This callback is called for each function if the Parser was initialized with SkipFunctionBodies set t...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getParenType(QualType NamedType) const
unsigned getIntWidth(QualType T) const
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
ExternCContextDecl * getExternCContextDecl() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U)
Determine whether two function types are the same, ignoring exception specifications in cases where t...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getObjCClassType() const
Represents the Objective-C Class type.
QualType getRecordType(const RecordDecl *Decl) const
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
void addModuleInitializer(Module *M, Decl *Init)
Add a declaration to the list of declarations that are initialized for a module.
const LangOptions & getLangOpts() const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
void attachCommentsToJustParsedDecls(ArrayRef< Decl * > Decls, const Preprocessor *PP)
Searches existing comments for doc comments that should be attached to Decls.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
void setManglingNumber(const NamedDecl *ND, unsigned Number)
CanQualType UnsignedCharTy
CanQualType UnsignedIntTy
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
CanQualType UnsignedLongLongTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
CanQualType UnsignedShortTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
void setcudaConfigureCallDecl(FunctionDecl *FD)
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
const VariableArrayType * getAsVariableArrayType(QualType T) const
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
bool hasDirectOwnershipQualifier(QualType Ty) const
Return true if the type has been explicitly qualified with ObjC ownership.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void ResetObjCLayout(const ObjCContainerDecl *CD)
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
bool hasSameFunctionTypeIgnoringPtrSizes(QualType T, QualType U)
Determine whether two function types are the same, ignoring pointer sizes in the return type and para...
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
@ GE_Missing_stdio
Missing a type from <stdio.h>
@ GE_Missing_type
Missing a type.
@ GE_Missing_ucontext
Missing a type from <ucontext.h>
@ GE_Missing_setjmp
Missing a type from <setjmp.h>
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
AlignedAttr * clone(ASTContext &C) const
unsigned getAlignment(ASTContext &Ctx) const
static AllocAlignAttr * CreateImplicit(ASTContext &Ctx, ParamIdx ParamIndex, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static AllocSizeAttr * CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx NumElemsParam, const AttributeCommonInfo &CommonInfo={SourceRange{}})
llvm::StringRef getAnnotation() const
Wrapper for source info for arrays.
SourceLocation getLBracketLoc() const
Expr * getSizeExpr() const
TypeLoc getElementLoc() const
SourceLocation getRBracketLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
static AsmLabelAttr * Create(ASTContext &Ctx, llvm::StringRef Label, bool IsLiteralLabel, const AttributeCommonInfo &CommonInfo)
static AsmLabelAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, bool IsLiteralLabel, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Attr - This represents one attribute.
attr::Kind getKind() const
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user.
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
@ AS_Keyword
__ptr16, alignas(...), etc.
@ AS_Declspec
__declspec(...)
SourceRange getRange() const
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
AttributeFactory & getFactory() const
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
An attributed type is a type to which a type attribute has been applied.
QualType getModifiedType() const
bool isCallingConv() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
A builtin binary operation expression such as "x + y" or "x <= y".
static bool isCompoundAssignmentOp(Opcode Opc)
Represents a block literal declaration, which is like an unnamed FunctionDecl.
bool doesNotEscape() const
static BuiltinAttr * CreateImplicit(ASTContext &Ctx, unsigned ID, const AttributeCommonInfo &CommonInfo={SourceRange{}})
This class is used for builtin types like 'int'.
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool allowTypeMismatch(unsigned ID) const
Determines whether a declaration of this builtin should be recognized even if the type doesn't match ...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
void forgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
bool isConstWithoutErrno(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno.
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
const char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache",...
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
static C11NoReturnAttr * Create(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo)
cpus_iterator cpus_begin() const
unsigned cpus_size() const
unsigned cpus_size() const
cpus_iterator cpus_end() const
llvm::iterator_range< cpus_iterator > cpus() const
cpus_iterator cpus_begin() const
static CUDADeviceAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static CUDAHostAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceLocation getEndLoc() const LLVM_READONLY
Represents a call to a C++ constructor.
bool isElidable() const
Whether this construction is elidable.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Represents a C++ conversion function within a class.
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, ExplicitSpecifier ES, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
static CXXDeductionGuideDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, SourceLocation EndLocation)
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
A mapping from each virtual member function to its set of final overriders.
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class....
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
base_class_iterator bases_end()
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
CXXRecordDecl * getDefinition() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
base_class_iterator bases_begin()
capture_const_range captures() const
bool hasDefinition() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
LambdaCaptureDefault getLambdaCaptureDefault() const
void setDescribedClassTemplate(ClassTemplateDecl *Template)
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6,...
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
char * location_data() const
Retrieve the data associated with the source-location information.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isCallToStdMove() const
static CallbackAttr * CreateImplicit(ASTContext &Ctx, int *Encoding, unsigned EncodingSize, const AttributeCommonInfo &CommonInfo={SourceRange{}})
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CastKind getCastKind() const
static CharSourceRange getCharRange(SourceRange R)
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a function specialization at template class scope.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, const TemplateArgumentListInfo &TemplateArgs)
Declaration of a class template.
ConditionalOperator - The ?: ternary operator.
static ConstAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static ConstInitAttr * Create(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo)
static unsigned getNumAddressingBits(const ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
static unsigned getMaxSizeBits(const ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
DLLExportAttr * clone(ASTContext &C) const
static DLLExportAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static DLLImportAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isObjCContainer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Decl::Kind getDeclKind() const
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
bool hasAutoTypeSpec() const
static const TST TST_typename
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
void ClearStorageClassSpecs()
static const TST TST_underlyingType
bool isNoreturnSpecified() const
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
SourceLocation getNoreturnSpecLoc() const
bool isExternInLinkageSpec() const
static const TST TST_union
SCS
storage-class-specifier
SourceLocation getExplicitSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
ParsedType getRepAsType() const
void UpdateTypeRep(ParsedType Rep)
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
static const TST TST_enum
static const TST TST_decltype
static bool isDeclRep(TST T)
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_class
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_atomic
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
bool isFriendSpecified() const
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
CXXScopeSpec & getTypeSpecScope()
SourceLocation getTypeSpecTypeLoc() const
void UpdateExprRep(Expr *Rep)
static const TSCS TSCS_thread_local
static const TST TST_error
ExplicitSpecifier getExplicitSpecifier() const
bool isTypeSpecOwned() const
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_typeofType
static const TST TST_auto
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAttrs(const AttrVec &Attrs)
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void setTopLevelDeclInObjCContainer(bool V=true)
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isInIdentifierNamespace(unsigned NS) const
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
@ FOK_Declared
A friend of a previously-declared entity.
bool isReferenced() const
Whether any declaration of this entity was referenced.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
Represents a ValueDecl that came out of a declarator.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Expr * getAsmLabel() const
FunctionDefinitionKind getFunctionDefinitionKind() const
const ParsedAttributes & getAttributes() const
void setRedeclaration(bool Val)
SourceLocation getIdentifierLoc() const
SourceLocation getEndLoc() const LLVM_READONLY
Expr * getTrailingRequiresClause()
Sets a trailing requires clause for this declarator.
void setInvalidType(bool Val=true)
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool hasInitializer() const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
IdentifierInfo * getIdentifier() const
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
bool isStaticMember()
Returns true if this declares a static member.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A decomposition declaration.
static DecompositionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation LSquareLoc, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< BindingDecl * > Bindings)
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
Common base class for placeholders for types that get replaced by placeholder type deduction: C++11 a...
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it's either not been deduced or was deduce...
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Concrete class used by the front-end to report problems and issues.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
An instance of this object exists for each enum constant that is defined.
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
const Expr * getInitExpr() const
const llvm::APSInt & getInitVal() const
enumerator_range enumerators() const
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
bool isComplete() const
Returns true if this can be considered a complete type.
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
void setPromotionType(QualType T)
Set the promotion type.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant,...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
bool isZeroLengthBitField(const ASTContext &Ctx) const
Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
static FinalAttr * Create(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo)
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isPure() const
Whether this virtual function is pure, i.e.
ConstexprSpecKind getConstexprKind() const
void setPreviousDeclaration(FunctionDecl *PrevDecl)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
void setHasSkippedBody(bool Skipped=true)
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
bool hasWrittenPrototype() const
Whether this function has a written prototype.
void setWillHaveBody(bool V=true)
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isDeleted() const
Whether this function has been deleted.
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
void setPure(bool P=true)
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
@ TK_MemberSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isReplaceableGlobalAllocationFunction(Optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
void setDefaulted(bool D=true)
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
bool isGlobal() const
Determines whether this is a global function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
DeclarationNameInfo getNameInfo() const
void setDeletedAsWritten(bool D=true)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
QualType getParamType(unsigned i) const
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > getParamTypes() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or nullptr if no such declaration exists...
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
void mergePrevDecl(FunctionTemplateDecl *Prev)
Merge Prev with our RedeclarableTemplateDecl::Common.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
Wrapper for source info for functions.
SourceLocation getLParenLoc() const
A class which abstracts out some details necessary for making a call.
ExtInfo withCallingConv(CallingConv cc) const
CallingConv getCC() const
ExtInfo withProducesResult(bool producesResult) const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
ExtInfo withNoReturn(bool noReturn) const
bool getHasRegParm() const
bool getProducesResult() const
ExtInfo withNoCallerSavedRegs(bool noCallerSavedRegs) const
ExtInfo withRegParm(unsigned RegParm) const
FunctionType - C99 6.7.5.3 - Function Declarators.
ExtInfo getExtInfo() const
static StringRef getNameForCallConv(CallingConv CC)
unsigned getRegParmType() const
CallingConv getCallConv() const
QualType getReturnType() const
bool getCmseNSCallAttr() const
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
StringRef getName() const
Return the actual identifier string.
iterator - Iterate over the decls of a specified declaration name.
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void InsertDeclAfter(iterator Pos, NamedDecl *D)
Insert the given declaration after the given iterator position.
iterator end()
end - Returns an iterator that has 'finished'.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false) const
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
Describes an C or C++ initializer list.
static InitSegAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the declaration of a label.
bool isResolvedMSAsmLabel() const
LabelStmt * getStmt() const
bool isMSAsmLabel() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
clang::ObjCRuntime ObjCRuntime
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
void push_back(const T &LocalValue)
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
Represents a linkage specification.
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
void InstantiatedLocal(const Decl *D, Decl *Inst)
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
LookupResultKind getResultKind() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
DeclarationName getLookupName() const
Gets the name to look up.
@ AmbiguousTagHiding
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
virtual unsigned getStaticLocalNumber(const VarDecl *VD)=0
Static locals are numbered by source order.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
SourceLocation DefinitionLoc
The location of the module definition.
Module * Parent
The parent of this module.
ModuleKind Kind
The kind of this module.
bool isModulePurview() const
Does this Module scope describe part of the purview of a named C++ module?
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isLinkageValid() const
True if the computed linkage is valid.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Visibility getVisibility() const
Determines the visibility of this entity.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isExternallyVisible() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represent a C++ namespace.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool containsErrors() const
Whether this nested name specifier contains an error.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
static NoThrowAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static llvm::Optional< MapTypeTy > isDeclareTargetDeclaration(const ValueDecl *VD)
static llvm::Optional< DevTypeTy > getDeviceType(const ValueDecl *VD)
ObjCCategoryDecl - Represents a category declaration.
ObjCCompatibleAliasDecl - Represents alias of a class.
ObjCContainerDecl - Represents a container for method declarations.
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
known_extensions_range known_extensions() const
ObjCIvarDecl - Represents an ObjC instance variable.
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl - Represents an instance or class method declaration.
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
ParmVarDecl *const * param_iterator
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
bool isEnabled(llvm::StringRef Ext) const
static OverloadableAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
MapType::iterator iterator
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
OwnershipKind getOwnKind() const
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
unsigned getNumExprs() const
Return the number of expressions in this paren list.
void setRParenLoc(SourceLocation Loc)
TypeLoc getInnerLoc() const
void setLParenLoc(SourceLocation Loc)
Sugar for parentheses used when specifying types.
Represents a parameter to a function.
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
ObjCDeclQualifier getObjCDeclQualifier() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
QualType getOriginalType() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
ParsedAttr - Represents a syntactic attribute.
bool hasAttribute(ParsedAttr::Kind K) const
ParsedAttributes - A collection of parsed attributes.
AttributePool & getPool() const
unsigned getDiagID() const
TypeLoc getPointeeLoc() const
Wrapper for source info for pointers.
void setStarLoc(SourceLocation Loc)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
static PragmaClangBSSSectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static PragmaClangDataSectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static PragmaClangRelroSectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static PragmaClangRodataSectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static PragmaClangTextSectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
HeaderSearch & getHeaderSearchInfo() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef< TokenValue > Tokens) const
Return the name of the macro defined before Loc that has spelling Tokens.
static PureAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
PrimitiveDefaultInitializeKind
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
QualType withoutLocalFastQualifiers() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PrimitiveCopyKind isNonTrivialToPrimitiveCopy() const
Check if this is a non-trivial type that would cause a C struct transitively containing this type to ...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
PrimitiveDefaultInitializeKind isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C struct types.
bool isObjCGCStrong() const
true when Type is objc's strong.
bool isConstQualified() const
Determine whether this type is const-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
@ PCK_Trivial
The type does not fall into any of the following categories.
@ PCK_VolatileTrivial
The type would be trivial except that it is volatile-qualified.
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Check if this is or contains a C union that is non-trivial to default-initialize, which is a union th...
A qualifier set is used to build a set of qualifiers.
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
ObjCLifetime getObjCLifetime() const
Represents a struct/union/class.
bool hasObjectMember() const
field_range fields() const
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
virtual void completeDefinition()
Note that the definition of this type is now complete.
@ APK_CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
void setMemberSpecialization()
Note that this member template is a specialization.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
redecl_iterator redecls_end() const
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
static ReturnsNonNullAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
static ReturnsTwiceAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isCompoundStmtScope() const
Determine whether this scope is a compound statement scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ DeclScope
This is a scope that can contain a declaration.
static SectionAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Name, const AttributeCommonInfo &CommonInfo={SourceRange{}})
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
static NameClassification DependentNonType()
static NameClassification VarTemplate(TemplateName Name)
static NameClassification Unknown()
static NameClassification OverloadSet(ExprResult E)
static NameClassification UndeclaredTemplate(TemplateName Name)
static NameClassification FunctionTemplate(TemplateName Name)
static NameClassification NonType(NamedDecl *D)
static NameClassification Concept(TemplateName Name)
static NameClassification UndeclaredNonType()
static NameClassification TypeTemplate(TemplateName Name)
static NameClassification Error()
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
A generic diagnostic builder for errors which may or may not be deferred.
Sema - This implements semantic analysis and AST building for C.
QualType SubstAutoType(QualType TypeWithAuto, QualType Replacement)
Substitute Replacement for auto in TypeWithAuto.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
Attr * getImplicitCodeSegOrSectionAttrForFunction(const FunctionDecl *FD, bool IsDefinition)
Returns an implicit CodeSegAttr if a __declspec(code_seg) is found on a containing class.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
Scope * getCurScope() const
Retrieve the parser's current scope.
void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, LookupResult &OldDecls)
MergeTypedefNameDecl - We just parsed a typedef 'New' which has the same name and scope as a previous...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
bool hasStructuralCompatLayout(Decl *D, Decl *Suggested)
Determine if D and Suggested have a structurally compatible layout as described in C11 6....
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
void checkDeviceDecl(ValueDecl *D, SourceLocation Loc)
Check if the expression is allowed to be used in expressions for the offloading devices.
void adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, SourceLocation Loc)
Adjust the calling convention of a method to be the ABI default if it wasn't specified explicitly.
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth, bool *ZeroWidth=nullptr)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width,...
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false)
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S',...
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupLocalFriendName
Look up a friend of a local class.
@ LookupRedeclarationWithLinkage
Look up an ordinary name that is going to be redeclared as a name with linkage.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
@ NTCUC_DefaultInitializedObject
void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, uint64_t MagicValue, QualType Type, bool LayoutCompatible, bool MustBeNull)
Register a magic integral constant to be used as a type tag.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs, SourceLocation AttrEnd)
void LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
void ProcessPragmaWeak(Scope *S, Decl *D)
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class,...
NoSpeculativeLoadHardeningAttr * mergeNoSpeculativeLoadHardeningAttr(Decl *D, const NoSpeculativeLoadHardeningAttr &AL)
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
FunctionEmissionStatus
Status of the function emission on the CUDA/HIP/OpenMP host/device attrs.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
PragmaClangSection PragmaClangRodataSection
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
TranslationUnitKind TUKind
The kind of translation unit we are processing.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
void ActOnExitFunctionContext()
bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, const TemplateArgumentListInfo &ExplicitTemplateArgs, LookupResult &Previous)
Perform semantic analysis for the given dependent function template specialization.
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result, Optional< unsigned > DependentDeductionDepth=None, bool IgnoreConstraints=false)
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
Preprocessor & getPreprocessor() const
void deduceOpenCLAddressSpace(ValueDecl *decl)
PragmaStack< StringLiteral * > CodeSegStack
void AddRangeBasedOptnone(FunctionDecl *FD)
Only called on function definitions; if there is a pragma in scope with the effect of a range-based o...
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
static NamedDecl * getAsTemplateNameDecl(NamedDecl *D, bool AllowFunctionTemplates=true, bool AllowDependent=true)
Try to interpret the lookup result D as a template-name.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
TemplateParameterList * MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, SourceLocation DeclLoc, const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, ArrayRef< TemplateParameterList * > ParamLists, bool IsFriend, bool &IsMemberSpecialization, bool &Invalid, bool SuppressDiagnostic=false)
Match the given template parameter lists to the given scope specifier, returning the template paramet...
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
void AddAlignmentAttributesForRecord(RecordDecl *RD)
AddAlignmentAttributesForRecord - Adds any needed alignment attributes to a the record decl,...
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
void setCurrentOpenCLExtensionForDecl(Decl *FD)
Set current OpenCL extensions for a declaration which can only be used when these OpenCL extensions a...
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
HandleField - Analyze a field of a C struct or a C++ data member.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool isAddressOfOperand, const TemplateArgumentListInfo *TemplateArgs)
ActOnDependentIdExpression - Handle a dependent id-expression that was just parsed.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
Decl * getObjCDeclContext() const
const AttributedType * getCallingConvAttributedType(QualType T) const
Get the outermost AttributedType node that sets a calling convention.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
DiagnosticsEngine & getDiagnostics() const
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
bool LookupBuiltin(LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
ASTContext & getASTContext() const
void translateTemplateArguments(const ASTTemplateArgsPtr &In, TemplateArgumentListInfo &Out)
Translates template arguments as provided by the parser into template arguments used by semantic anal...
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
void PopExpressionEvaluationContext()
PragmaStack< StringLiteral * > ConstSegStack
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
void inferGslPointerAttribute(NamedDecl *ND, CXXRecordDecl *UnderlyingRecord)
Add gsl::Pointer attribute to std::container::iterator.
bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn)
We've just determined that Old and New both appear to be definitions of the same variable.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
void MarkTypoCorrectedFunctionDefinition(const NamedDecl *F)
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
@ TPL_TemplateMatch
We are matching the template parameter lists of two templates that might be redeclarations.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority)
Attribute merging methods. Return true if a new attribute was added.
EnumDecl * getStdAlignValT() const
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
CommonAttr * mergeCommonAttr(Decl *D, const ParsedAttr &AL)
bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, TemplateArgumentListInfo *ExplicitTemplateArgs, LookupResult &Previous, bool QualifiedFriend=false)
Perform semantic analysis for the given function template specialization.
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, SourceLocation IdLoc=SourceLocation())
Check declaration inside target region.
void PushFunctionScope()
Enter a new function scope.
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
void inferGslOwnerPointerAttribute(CXXRecordDecl *Record)
Add [[gsl::Owner]] and [[gsl::Pointer]] attributes for std:: types.
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
sema::LambdaScopeInfo * PushLambdaScope()
@ UPPC_FixedUnderlyingType
The fixed underlying type of an enumeration.
@ UPPC_EnumeratorValue
The enumerator value.
@ UPPC_Initializer
An initializer.
@ UPPC_DeclarationType
The type of an arbitrary declaration.
@ UPPC_DeclarationQualifier
A declaration qualifier.
@ UPPC_DataMemberType
The type of a data member.
@ UPPC_BitFieldWidth
The size of a bit-field.
void checkAllowedCUDAInitializer(VarDecl *VD)
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
bool RebuildTemplateParamsInCurrentInstantiation(TemplateParameterList *Params)
Rebuild the template parameters now that we know we're in a current instantiation.
void DiagnoseInvalidJumps(Stmt *Body)
SourceLocation CurInitSegLoc
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
void EnterTemplatedContext(Scope *S, DeclContext *DC)
Enter a template parameter scope, after it's been associated with a particular DeclContext.
void CheckAlignasUnderalignment(Decl *D)
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old)
We've determined that New is a redeclaration of Old.
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope(Decl *D, SmallVectorImpl< FunctionDecl * > &Bases)
Register D as specialization of all base functions in Bases in the current omp begin/end declare vari...
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
NamedDecl * getShadowedDeclaration(const TypedefNameDecl *D, const LookupResult &R)
Return the declaration shadowed by the given typedef D, or null if it doesn't shadow any declaration ...
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
const LangOptions & LangOpts
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope, ArrayRef< BindingDecl * > Bindings=None)
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
CXXRecordDecl * getStdBadAlloc() const
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
PragmaClangSection PragmaClangRelroSection
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
bool TemplateParameterListsAreEqual(TemplateParameterList *New, TemplateParameterList *Old, bool Complain, TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc=SourceLocation())
Determine whether the given template parameter lists are equivalent.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
bool checkUnsafeAssigns(SourceLocation Loc, QualType LHS, Expr *RHS)
checkUnsafeAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained type.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
void MaybeAddCUDAConstantAttr(VarDecl *VD)
May add implicit CUDAConstantAttr attribute to VD, depending on VD and current compilation settings.
TypeLoc getReturnTypeLoc(FunctionDecl *FD) const
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used,...
PragmaStack< StringLiteral * > BSSSegStack
bool hasAnyAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true, bool AllowNonTemplateFunctions=false)
DeclContext * getCurLexicalContext() const
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T, TagDecl *OwnedTagDecl=nullptr)
Retrieve a version of the type 'T' that is elaborated by Keyword, qualified by the nested-name-specif...
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
void ExitDeclaratorContext(Scope *S)
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP declare target region.
void DiagnoseShadowingLambdaDecls(const sema::LambdaScopeInfo *LSI)
Diagnose shadowing for variables shadowed in the lambda record LambdaRD when these variables are capt...
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
sema::FunctionScopeInfo * getCurFunction() const
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
FunctionDecl * CreateBuiltin(IdentifierInfo *II, QualType Type, unsigned ID, SourceLocation Loc)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
bool CheckNontrivialField(FieldDecl *FD)
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
void AddPushedVisibilityAttribute(Decl *RD)
AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, add an appropriate visibility at...
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
QualType DeduceTemplateSpecializationFromInitializer(TypeSourceInfo *TInfo, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Init)
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
ExprResult DefaultLvalueConversion(Expr *E)
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
StringLiteral * CurInitSeg
Last section used with #pragma init_seg.
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so,...
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
void DiagnoseAutoDeductionFailure(VarDecl *VDecl, Expr *Init)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
@ ForExternalRedeclaration
The lookup results will be used for redeclaration of a name with external linkage; non-visible lookup...
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D)
Act on D, a function definition inside of an omp [begin/end] assumes.
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
void CompleteMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
void maybeAddCUDAHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration.
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
void notePreviousDefinition(const NamedDecl *Old, SourceLocation New)
bool isInOpenMPDeclareVariantScope() const
Can we exit an OpenMP declare variant scope at the moment.
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsMemberSpecialization)
Perform semantic checking of a new function declaration.
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool canFullyTypeCheckRedeclaration(ValueDecl *NewD, ValueDecl *OldD, QualType NewT, QualType OldT)
Determines if we can perform a correct type check for D as a redeclaration of PrevDecl.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
@ NTK_TemplateTemplateArgument
void ActOnObjCContainerFinishDefinition()
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible.
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
bool areMultiversionVariantFunctionsCompatible(const FunctionDecl *OldFD, const FunctionDecl *NewFD, const PartialDiagnostic &NoProtoDiagID, const PartialDiagnosticAt &NoteCausedDiagIDAt, const PartialDiagnosticAt &NoSupportDiagIDAt, const PartialDiagnosticAt &DiffDiagIDAt, bool TemplatesSupported, bool ConstexprSupported, bool CLinkageMayDiffer)
Checks if the variant/multiversion functions are compatible.
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
PragmaClangSection PragmaClangTextSection
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
PragmaClangSection PragmaClangDataSection
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
void ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, SmallVectorImpl< FunctionDecl * > &Bases)
The declarator D defines a function in the scope S which is nested in an omp begin/end declare varian...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
void FilterAcceptableTemplateNames(LookupResult &R, bool AllowFunctionTemplates=true, bool AllowDependent=true)
void * SkippedDefinitionContext
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
void ActOnObjCReenterContainerContext(DeclContext *DC)
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname.
bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams)
Check whether a template can be declared within this scope.
void AddMsStructLayoutForRecord(RecordDecl *RD)
AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record.
MaybeODRUseExprSet MaybeODRUseExprs
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous)
Perform semantic analysis for the given non-template member specialization.
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void setFunctionHasBranchProtectedScope()
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl, bool Final=false)
LazyDeclPtr StdNamespace
The C++ "std" namespace, where the standard library resides.
DeclResult ActOnVarTemplateSpecialization(Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization)
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
SpeculativeLoadHardeningAttr * mergeSpeculativeLoadHardeningAttr(Decl *D, const SpeculativeLoadHardeningAttr &AL)
@ CCEK_Enumerator
Enumerator value with fixed underlying type.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
OverloadKind CheckOverload(Scope *S, FunctionDecl *New, const LookupResult &OldDecls, NamedDecl *&OldDecl, bool IsForUsingDecl)
Determine whether the given New declaration is an overload of the declarations in Old.
@ Ovl_NonFunction
This is not an overload because the lookup results contain a non-function.
@ Ovl_Overload
This is a legitimate overload: the existing declarations are functions or function templates with dif...
@ Ovl_Match
This is not an overload because the signature exactly matches an existing declaration.
SmallVector< ExprWithCleanups::CleanupObject, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
void AddKnownFunctionAttributesForReplaceableGlobalAllocationFunction(FunctionDecl *FD)
If this function is a C++ replaceable global allocation function (C++2a [basic.stc....
bool inferObjCARCLifetime(ValueDecl *decl)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ AMK_None
Don't merge availability attributes at all.
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
void CheckStaticLocalForDllExport(VarDecl *VD)
Check if VD needs to be dllexport/dllimport due to being in a dllexport/import function.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl)
Checks if the new declaration declared in dependent context must be put in the same redeclaration cha...
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void DiscardCleanupsInEvaluationContext()
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New)
void makeMergedDefinitionVisible(NamedDecl *ND)
Make a merged definition of an existing hidden definition ND visible at the specified location.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
SourceManager & SourceMgr
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure.
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, bool IncludeCXX11Attributes=true)
DiagnosticsEngine & Diags
OpenCLOptions & getOpenCLOptions()
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
NamespaceDecl * getStdNamespace() const
RedeclarationKind forRedeclarationInCurContext()
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
PragmaStack< StringLiteral * > DataSegStack
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body.
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)
void CheckFunctionOrTemplateParamDeclarator(Scope *S, Declarator &D)
Common checks for a parameter-declaration that should apply to both function parameters and non-type ...
@ TPC_FriendFunctionTemplate
@ TPC_ClassTemplateMember
@ TPC_FriendFunctionTemplateDefinition
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void DiagnoseUnusedDecl(const NamedDecl *ND)
DiagnoseUnusedDecl - Emit warnings about declarations that are not used unless they are marked attr(u...
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope.
void ActOnUninitializedDecl(Decl *dcl)
void checkNonTrivialCUnionInInitializer(const Expr *Init, SourceLocation Loc)
Emit diagnostics if the initializer or any of its explicit or implicitly-generated subexpressions req...
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope.
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionExceptionSpec - Checks whether the exception spec is a subset of base spec.
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
bool RequireCompleteSizedType(SourceLocation Loc, QualType T, unsigned DiagID, const Ts &... Args)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, SkipBodyInfo *SkipBody=nullptr)
Checks the validity of a template parameter list, possibly considering the template parameter list fr...
void ActOnCXXForRangeDecl(Decl *D)
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc, bool IsTemplateId)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
std::tuple< MangleNumberingContext *, Decl * > getCurrentMangleNumberContext(const DeclContext *DC)
Compute the mangling number context for a lambda expression or block literal.
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
PragmaClangSection PragmaClangBSSSection
Decl * ActOnDeclarator(Scope *S, Declarator &D)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
LazyDeclPtr StdAlignValT
The C++ "std::align_val_t" enum class, which is defined by the C++ standard library.
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
void CheckVariableDeclarationType(VarDecl *NewVD)
unsigned getTemplateDepth(Scope *S) const
Determine the number of levels of enclosing template parameters.
CXXSpecialMember
Kinds of C++ special members.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit, Expr *Init)
std::string getCudaConfigureFuncName() const
Returns the name of the launch configuration function.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
llvm::SmallPtrSet< const NamedDecl *, 4 > TypoCorrectedFunctionDefinitions
The function definitions which were renamed as part of typo-correction to match their respective decl...
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
IdentifierResolver IdResolver
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, UnresolvedLookupExpr *AsULE=nullptr)
Builds an expression which might be an implicit member expression.
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void DiagnoseSizeOfParametersAndReturnValue(ArrayRef< ParmVarDecl * > Parameters, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
void CheckDeductionGuideTemplate(FunctionTemplateDecl *TD)
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
TemplateNameKindForDiagnostics
Describes the detailed kind of a template name. Used in diagnostics.
void checkCUDATargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool IsFixed, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD=nullptr)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
static StrictFPAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
static TagDecl * castFromDeclContext(const DeclContext *DC)
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
TagKind getTagKind() const
ParsedTargetAttr parse() const
bool isDefaultVersion() const
llvm::StringRef getFeaturesStr() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
Exposes information about the current target.
virtual bool validateCpuIs(StringRef Name) const
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual bool validateCpuSupports(StringRef Name) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool allowDebugInfoForExternalVar() const
Whether target allows debuginfo types for decl only variables.
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
A convenient class for passing around template argument information.
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getRAngleLoc() const
SourceLocation getTemplateLoc() const
Represents a type template specialization; the template must be a class template, a type alias templa...
static bool anyInstantiationDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args)
Token - This structure provides full information about a lexed token.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
Represents a declaration of a type.
void setTypeForDecl(const Type *TD)
const Type * getTypeForDecl() const
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
void setNameLoc(SourceLocation Loc)
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool isIncompleteArrayType() const
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
bool isConstantArrayType() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
bool isFunctionPointerType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
bool isReferenceType() const
bool isScalarType() const
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
const RecordType * getAsStructureType() const
bool containsErrors() const
Whether this type is an error type.
bool isFunctionProtoType() const
bool isObjCIdType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isObjCObjectType() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
const T * getAsAdjusted() const
Member-template getAsAdjusted<specific type>.
bool isFunctionType() const
bool isObjCObjectPointerType() const
bool isMemberFunctionPointerType() const
bool isFloatingType() const
bool isAnyPointerType() const
bool hasAutoForTrailingReturnType() const
Determine whether this type was written with a leading 'auto' corresponding to a trailing return type...
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
bool isFunctionNoProtoType() const
bool isReserveIDT() const
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Represents the declaration of a typedef-name via the 'typedef' type specifier.
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
QualType getUnderlyingType() const
void setTypeSourceInfo(TypeSourceInfo *newType)
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Simple class containing the result of Sema::CorrectTypo.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
@ IR_ARCFieldWithOwnership
static UnavailableAttr * CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, ImplicitReason ImplicitReason, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Represents a C++ unqualified-id that has been parsed.
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
The iterator over UnresolvedSets.
UsedAttr * clone(ASTContext &C) const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
void setCXXForRangeDecl(bool FRD)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
TLSKind getTLSKind() const
void setInitStyle(InitializationStyle Style)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
@ ListInit
Direct list-initialization (C++11)
@ CallInit
Call-style initialization (C++98)
void setStorageClass(StorageClass SC)
void setPreviousDeclInSameBlockScope(bool Same)
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
void setInlineSpecified()
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the initializer of this variable to determine whether it's a constant initializer.
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
void setConstexpr(bool IC)
@ TLS_Static
TLS with a known-constant initializer.
@ TLS_Dynamic
TLS with a dynamic initializer.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ TentativeDefinition
This declaration is a tentative definition.
@ DeclarationOnly
This declaration is only a declaration.
@ Definition
This declaration is definitely a definition.
void setDescribedVarTemplate(VarTemplateDecl *Template)
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
static WeakAttr * CreateImplicit(ASTContext &Ctx, const AttributeCommonInfo &CommonInfo={SourceRange{}})
Captures information about a #pragma weak directive.
void disableCheckFallThrough()
Policy getDefaultPolicy()
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
VarDecl * getVariable() const
void addVLATypeCapture(SourceLocation Loc, const VariableArrayType *VLAType, QualType CaptureType)
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, bool Invalid)
SmallVector< Capture, 4 > Captures
Captures - The captures.
ImplicitCaptureStyle ImpCaptureStyle
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, bool ByCopy)
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Retains information about a function, method, or block that is currently being parsed.
bool UsesFPIntrin
Whether this function uses constrained floating point intrinsics.
void addByrefBlockVar(VarDecl *VD)
bool NeedsScopeChecking() const
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
llvm::SmallVector< ShadowedOuterDecl, 4 > ShadowingDecls
CXXRecordDecl * Lambda
The class that describes the lambda.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool Mutable
Whether this is a mutable lambda.
Defines the clang::TargetInfo interface.
const AstTypeMatcher< RecordType > recordType
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Dataflow Directional Tag Classes.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
TypeSpecifierType
Specifies the kind of type.
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ GVA_AvailableExternally
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
ConstexprSpecKind
Define the kind of constexpr specifier.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_NoInit
No in-class initializer.
@ LCK_ByRef
Capturing by reference.
@ IK_DeductionGuideName
A deduction-guide name (a template-name)
@ IK_ImplicitSelfParam
An implicit 'self' parameter.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_ConstructorTemplateId
A constructor named via a template-id.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ IK_ConversionFunctionId
A conversion function name, e.g., operator int.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
@ TSCS_thread_local
C++11 thread_local.
@ TSCS__Thread_local
C11 _Thread_local.
@ TSCS___thread
GNU __thread.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
MutableArrayRef< Expr * > MultiExprArg
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
TemplateDecl * getAsTypeTemplateDecl(Decl *D)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
TagTypeKind
The kind of a tag type.
@ TTK_Class
The "class" keyword.
@ TTK_Enum
The "enum" keyword.
@ TTK_Struct
The "struct" keyword.
@ TTK_Union
The "union" keyword.
@ TTK_Interface
The "__interface" keyword.
LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...
bool isDiscardableGVALinkage(GVALinkage L)
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ TU_Complete
The translation unit is a complete translation unit.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
@ VK_RValue
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ ETK_Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
@ ETK_None
No keyword precedes the qualified type name.
@ EST_None
no exception specification
@ EST_BasicNoexcept
noexcept
Visibility
Describes the different kinds of visibility that a declaration may have.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword).
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
const DeclarationNameLoc & getInfo() const
struct CXXOpName CXXOperatorName
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
One instance of this struct is used for each type in a declarator that is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
enum clang::DeclaratorChunk::@205 Kind
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
MemberPointerTypeInfo Mem
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
EvalResult is a struct with detailed info about an evaluated expression.
Extra information about a function prototype.
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation PragmaLocation
Information about a template-id annotation token.
unsigned NumArgs
NumArgs - The number of template arguments.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.